Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> |
| 3 | * Creative Labs, Inc. |
| 4 | * Routines for control of EMU10K1 chips |
| 5 | * |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 6 | * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * Added support for Audigy 2 Value. |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 8 | * Added EMU 1010 support. |
| 9 | * General bug fixes and enhancements. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * |
| 12 | * BUGS: |
| 13 | * -- |
| 14 | * |
| 15 | * TODO: |
| 16 | * -- |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or modify |
| 19 | * it under the terms of the GNU General Public License as published by |
| 20 | * the Free Software Foundation; either version 2 of the License, or |
| 21 | * (at your option) any later version. |
| 22 | * |
| 23 | * This program is distributed in the hope that it will be useful, |
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | * GNU General Public License for more details. |
| 27 | * |
| 28 | * You should have received a copy of the GNU General Public License |
| 29 | * along with this program; if not, write to the Free Software |
| 30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include <sound/driver.h> |
| 35 | #include <linux/delay.h> |
| 36 | #include <linux/init.h> |
| 37 | #include <linux/interrupt.h> |
| 38 | #include <linux/pci.h> |
| 39 | #include <linux/slab.h> |
| 40 | #include <linux/vmalloc.h> |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 41 | #include <linux/mutex.h> |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | #include <sound/core.h> |
| 45 | #include <sound/emu10k1.h> |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 46 | #include <linux/firmware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include "p16v.h" |
James Courtier-Dutton | e2b15f8 | 2005-11-11 23:39:05 +0100 | [diff] [blame] | 48 | #include "tina2.h" |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 49 | #include "p17v.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 51 | |
Clemens Ladisch | 7e0af29 | 2007-05-03 17:59:54 +0200 | [diff] [blame] | 52 | #define HANA_FILENAME "emu/hana.fw" |
| 53 | #define DOCK_FILENAME "emu/audio_dock.fw" |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 54 | #define EMU1010B_FILENAME "emu/emu1010b.fw" |
| 55 | #define MICRO_DOCK_FILENAME "emu/micro_dock.fw" |
Clemens Ladisch | 7e0af29 | 2007-05-03 17:59:54 +0200 | [diff] [blame] | 56 | |
| 57 | MODULE_FIRMWARE(HANA_FILENAME); |
| 58 | MODULE_FIRMWARE(DOCK_FILENAME); |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 59 | MODULE_FIRMWARE(EMU1010B_FILENAME); |
| 60 | MODULE_FIRMWARE(MICRO_DOCK_FILENAME); |
Clemens Ladisch | 7e0af29 | 2007-05-03 17:59:54 +0200 | [diff] [blame] | 61 | |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | /************************************************************************* |
| 64 | * EMU10K1 init / done |
| 65 | *************************************************************************/ |
| 66 | |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 67 | void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int ch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | { |
| 69 | snd_emu10k1_ptr_write(emu, DCYSUSV, ch, 0); |
| 70 | snd_emu10k1_ptr_write(emu, IP, ch, 0); |
| 71 | snd_emu10k1_ptr_write(emu, VTFT, ch, 0xffff); |
| 72 | snd_emu10k1_ptr_write(emu, CVCF, ch, 0xffff); |
| 73 | snd_emu10k1_ptr_write(emu, PTRX, ch, 0); |
| 74 | snd_emu10k1_ptr_write(emu, CPF, ch, 0); |
| 75 | snd_emu10k1_ptr_write(emu, CCR, ch, 0); |
| 76 | |
| 77 | snd_emu10k1_ptr_write(emu, PSST, ch, 0); |
| 78 | snd_emu10k1_ptr_write(emu, DSL, ch, 0x10); |
| 79 | snd_emu10k1_ptr_write(emu, CCCA, ch, 0); |
| 80 | snd_emu10k1_ptr_write(emu, Z1, ch, 0); |
| 81 | snd_emu10k1_ptr_write(emu, Z2, ch, 0); |
| 82 | snd_emu10k1_ptr_write(emu, FXRT, ch, 0x32100000); |
| 83 | |
| 84 | snd_emu10k1_ptr_write(emu, ATKHLDM, ch, 0); |
| 85 | snd_emu10k1_ptr_write(emu, DCYSUSM, ch, 0); |
| 86 | snd_emu10k1_ptr_write(emu, IFATN, ch, 0xffff); |
| 87 | snd_emu10k1_ptr_write(emu, PEFE, ch, 0); |
| 88 | snd_emu10k1_ptr_write(emu, FMMOD, ch, 0); |
| 89 | snd_emu10k1_ptr_write(emu, TREMFRQ, ch, 24); /* 1 Hz */ |
| 90 | snd_emu10k1_ptr_write(emu, FM2FRQ2, ch, 24); /* 1 Hz */ |
| 91 | snd_emu10k1_ptr_write(emu, TEMPENV, ch, 0); |
| 92 | |
| 93 | /*** these are last so OFF prevents writing ***/ |
| 94 | snd_emu10k1_ptr_write(emu, LFOVAL2, ch, 0); |
| 95 | snd_emu10k1_ptr_write(emu, LFOVAL1, ch, 0); |
| 96 | snd_emu10k1_ptr_write(emu, ATKHLDV, ch, 0); |
| 97 | snd_emu10k1_ptr_write(emu, ENVVOL, ch, 0); |
| 98 | snd_emu10k1_ptr_write(emu, ENVVAL, ch, 0); |
| 99 | |
| 100 | /* Audigy extra stuffs */ |
| 101 | if (emu->audigy) { |
| 102 | snd_emu10k1_ptr_write(emu, 0x4c, ch, 0); /* ?? */ |
| 103 | snd_emu10k1_ptr_write(emu, 0x4d, ch, 0); /* ?? */ |
| 104 | snd_emu10k1_ptr_write(emu, 0x4e, ch, 0); /* ?? */ |
| 105 | snd_emu10k1_ptr_write(emu, 0x4f, ch, 0); /* ?? */ |
| 106 | snd_emu10k1_ptr_write(emu, A_FXRT1, ch, 0x03020100); |
| 107 | snd_emu10k1_ptr_write(emu, A_FXRT2, ch, 0x3f3f3f3f); |
| 108 | snd_emu10k1_ptr_write(emu, A_SENDAMOUNTS, ch, 0); |
| 109 | } |
| 110 | } |
| 111 | |
James Courtier-Dutton | 18f3c59 | 2005-12-21 22:05:29 +0100 | [diff] [blame] | 112 | static unsigned int spi_dac_init[] = { |
| 113 | 0x00ff, |
| 114 | 0x02ff, |
| 115 | 0x0400, |
| 116 | 0x0520, |
| 117 | 0x0600, |
| 118 | 0x08ff, |
| 119 | 0x0aff, |
| 120 | 0x0cff, |
| 121 | 0x0eff, |
| 122 | 0x10ff, |
| 123 | 0x1200, |
| 124 | 0x1400, |
| 125 | 0x1480, |
| 126 | 0x1800, |
| 127 | 0x1aff, |
| 128 | 0x1cff, |
| 129 | 0x1e00, |
| 130 | 0x0530, |
| 131 | 0x0602, |
| 132 | 0x0622, |
| 133 | 0x1400, |
| 134 | }; |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 135 | |
| 136 | static unsigned int i2c_adc_init[][2] = { |
| 137 | { 0x17, 0x00 }, /* Reset */ |
| 138 | { 0x07, 0x00 }, /* Timeout */ |
| 139 | { 0x0b, 0x22 }, /* Interface control */ |
| 140 | { 0x0c, 0x22 }, /* Master mode control */ |
| 141 | { 0x0d, 0x08 }, /* Powerdown control */ |
| 142 | { 0x0e, 0xcf }, /* Attenuation Left 0x01 = -103dB, 0xff = 24dB */ |
| 143 | { 0x0f, 0xcf }, /* Attenuation Right 0.5dB steps */ |
| 144 | { 0x10, 0x7b }, /* ALC Control 1 */ |
| 145 | { 0x11, 0x00 }, /* ALC Control 2 */ |
| 146 | { 0x12, 0x32 }, /* ALC Control 3 */ |
| 147 | { 0x13, 0x00 }, /* Noise gate control */ |
| 148 | { 0x14, 0xa6 }, /* Limiter control */ |
| 149 | { 0x15, ADC_MUX_2 }, /* ADC Mixer control. Mic for Audigy 2 ZS Notebook */ |
| 150 | }; |
James Courtier-Dutton | 18f3c59 | 2005-12-21 22:05:29 +0100 | [diff] [blame] | 151 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 152 | static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | unsigned int silent_page; |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 155 | int ch; |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 156 | u32 tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
| 158 | /* disable audio and lock cache */ |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 159 | outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, |
| 160 | emu->port + HCFG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | /* reset recording buffers */ |
| 163 | snd_emu10k1_ptr_write(emu, MICBS, 0, ADCBS_BUFSIZE_NONE); |
| 164 | snd_emu10k1_ptr_write(emu, MICBA, 0, 0); |
| 165 | snd_emu10k1_ptr_write(emu, FXBS, 0, ADCBS_BUFSIZE_NONE); |
| 166 | snd_emu10k1_ptr_write(emu, FXBA, 0, 0); |
| 167 | snd_emu10k1_ptr_write(emu, ADCBS, 0, ADCBS_BUFSIZE_NONE); |
| 168 | snd_emu10k1_ptr_write(emu, ADCBA, 0, 0); |
| 169 | |
| 170 | /* disable channel interrupt */ |
| 171 | outl(0, emu->port + INTE); |
| 172 | snd_emu10k1_ptr_write(emu, CLIEL, 0, 0); |
| 173 | snd_emu10k1_ptr_write(emu, CLIEH, 0, 0); |
| 174 | snd_emu10k1_ptr_write(emu, SOLEL, 0, 0); |
| 175 | snd_emu10k1_ptr_write(emu, SOLEH, 0, 0); |
| 176 | |
| 177 | if (emu->audigy){ |
| 178 | /* set SPDIF bypass mode */ |
| 179 | snd_emu10k1_ptr_write(emu, SPBYPASS, 0, SPBYPASS_FORMAT); |
| 180 | /* enable rear left + rear right AC97 slots */ |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 181 | snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_REAR_RIGHT | |
| 182 | AC97SLOT_REAR_LEFT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /* init envelope engine */ |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 186 | for (ch = 0; ch < NUM_G; ch++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | snd_emu10k1_voice_init(emu, ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 189 | snd_emu10k1_ptr_write(emu, SPCS0, 0, emu->spdif_bits[0]); |
| 190 | snd_emu10k1_ptr_write(emu, SPCS1, 0, emu->spdif_bits[1]); |
| 191 | snd_emu10k1_ptr_write(emu, SPCS2, 0, emu->spdif_bits[2]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Lee Revell | 2b637da | 2005-03-30 13:51:18 +0200 | [diff] [blame] | 193 | if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | /* Hacks for Alice3 to work independent of haP16V driver */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | //Setup SRCMulti_I2S SamplingRate |
| 196 | tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); |
| 197 | tmp &= 0xfffff1ff; |
| 198 | tmp |= (0x2<<9); |
| 199 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp); |
| 200 | |
| 201 | /* Setup SRCSel (Enable Spdif,I2S SRCMulti) */ |
| 202 | snd_emu10k1_ptr20_write(emu, SRCSel, 0, 0x14); |
| 203 | /* Setup SRCMulti Input Audio Enable */ |
| 204 | /* Use 0xFFFFFFFF to enable P16V sounds. */ |
| 205 | snd_emu10k1_ptr20_write(emu, SRCMULTI_ENABLE, 0, 0xFFFFFFFF); |
| 206 | |
| 207 | /* Enabled Phased (8-channel) P16V playback */ |
| 208 | outl(0x0201, emu->port + HCFG2); |
| 209 | /* Set playback routing. */ |
James Courtier-Dutton | fd9a98e | 2005-04-10 15:43:35 +0200 | [diff] [blame] | 210 | snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, 0x78e4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
James Courtier-Dutton | e0474e5 | 2005-07-02 16:33:34 +0200 | [diff] [blame] | 212 | if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | /* Hacks for Alice3 to work independent of haP16V driver */ |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 214 | snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | //Setup SRCMulti_I2S SamplingRate |
| 216 | tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); |
| 217 | tmp &= 0xfffff1ff; |
| 218 | tmp |= (0x2<<9); |
| 219 | snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp); |
| 220 | |
| 221 | /* Setup SRCSel (Enable Spdif,I2S SRCMulti) */ |
| 222 | outl(0x600000, emu->port + 0x20); |
| 223 | outl(0x14, emu->port + 0x24); |
| 224 | |
| 225 | /* Setup SRCMulti Input Audio Enable */ |
| 226 | outl(0x7b0000, emu->port + 0x20); |
| 227 | outl(0xFF000000, emu->port + 0x24); |
| 228 | |
| 229 | /* Setup SPDIF Out Audio Enable */ |
| 230 | /* The Audigy 2 Value has a separate SPDIF out, |
| 231 | * so no need for a mixer switch |
| 232 | */ |
| 233 | outl(0x7a0000, emu->port + 0x20); |
| 234 | outl(0xFF000000, emu->port + 0x24); |
| 235 | tmp = inl(emu->port + A_IOCFG) & ~0x8; /* Clear bit 3 */ |
| 236 | outl(tmp, emu->port + A_IOCFG); |
| 237 | } |
James Courtier-Dutton | 27fe864 | 2005-12-21 15:06:08 +0100 | [diff] [blame] | 238 | if (emu->card_capabilities->spi_dac) { /* Audigy 2 ZS Notebook with DAC Wolfson WM8768/WM8568 */ |
James Courtier-Dutton | 18f3c59 | 2005-12-21 22:05:29 +0100 | [diff] [blame] | 239 | int size, n; |
| 240 | |
| 241 | size = ARRAY_SIZE(spi_dac_init); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 242 | for (n = 0; n < size; n++) |
James Courtier-Dutton | 18f3c59 | 2005-12-21 22:05:29 +0100 | [diff] [blame] | 243 | snd_emu10k1_spi_write(emu, spi_dac_init[n]); |
| 244 | |
James Courtier-Dutton | 27fe864 | 2005-12-21 15:06:08 +0100 | [diff] [blame] | 245 | snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10); |
James Courtier-Dutton | ccadc3e | 2005-12-21 15:31:02 +0100 | [diff] [blame] | 246 | /* Enable GPIOs |
| 247 | * GPIO0: Unknown |
| 248 | * GPIO1: Speakers-enabled. |
| 249 | * GPIO2: Unknown |
| 250 | * GPIO3: Unknown |
| 251 | * GPIO4: IEC958 Output on. |
| 252 | * GPIO5: Unknown |
| 253 | * GPIO6: Unknown |
| 254 | * GPIO7: Unknown |
| 255 | */ |
| 256 | outl(0x76, emu->port + A_IOCFG); /* Windows uses 0x3f76 */ |
| 257 | |
James Courtier-Dutton | 27fe864 | 2005-12-21 15:06:08 +0100 | [diff] [blame] | 258 | } |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 259 | if (emu->card_capabilities->i2c_adc) { /* Audigy 2 ZS Notebook with ADC Wolfson WM8775 */ |
| 260 | int size, n; |
| 261 | |
| 262 | snd_emu10k1_ptr20_write(emu, P17V_I2S_SRC_SEL, 0, 0x2020205f); |
| 263 | tmp = inl(emu->port + A_IOCFG); |
| 264 | outl(tmp | 0x4, emu->port + A_IOCFG); /* Set bit 2 for mic input */ |
| 265 | tmp = inl(emu->port + A_IOCFG); |
| 266 | size = ARRAY_SIZE(i2c_adc_init); |
| 267 | for (n = 0; n < size; n++) |
| 268 | snd_emu10k1_i2c_write(emu, i2c_adc_init[n][0], i2c_adc_init[n][1]); |
| 269 | for (n=0; n < 4; n++) { |
| 270 | emu->i2c_capture_volume[n][0]= 0xcf; |
| 271 | emu->i2c_capture_volume[n][1]= 0xcf; |
| 272 | } |
| 273 | |
| 274 | } |
| 275 | |
James Courtier-Dutton | 27fe864 | 2005-12-21 15:06:08 +0100 | [diff] [blame] | 276 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); |
| 278 | snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */ |
| 279 | snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */ |
| 280 | |
| 281 | silent_page = (emu->silent_page.addr << 1) | MAP_PTI_MASK; |
| 282 | for (ch = 0; ch < NUM_G; ch++) { |
| 283 | snd_emu10k1_ptr_write(emu, MAPA, ch, silent_page); |
| 284 | snd_emu10k1_ptr_write(emu, MAPB, ch, silent_page); |
| 285 | } |
| 286 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 287 | if (emu->card_capabilities->emu1010) { |
| 288 | outl(HCFG_AUTOMUTE_ASYNC | |
| 289 | HCFG_EMU32_SLAVE | |
| 290 | HCFG_AUDIOENABLE, emu->port + HCFG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | /* |
| 292 | * Hokay, setup HCFG |
| 293 | * Mute Disable Audio = 0 |
| 294 | * Lock Tank Memory = 1 |
| 295 | * Lock Sound Memory = 0 |
| 296 | * Auto Mute = 1 |
| 297 | */ |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 298 | } else if (emu->audigy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | if (emu->revision == 4) /* audigy2 */ |
| 300 | outl(HCFG_AUDIOENABLE | |
| 301 | HCFG_AC3ENABLE_CDSPDIF | |
| 302 | HCFG_AC3ENABLE_GPSPDIF | |
| 303 | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); |
| 304 | else |
| 305 | outl(HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); |
James Courtier-Dutton | e0474e5 | 2005-07-02 16:33:34 +0200 | [diff] [blame] | 306 | /* FIXME: Remove all these emu->model and replace it with a card recognition parameter, |
| 307 | * e.g. card_capabilities->joystick */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } else if (emu->model == 0x20 || |
| 309 | emu->model == 0xc400 || |
| 310 | (emu->model == 0x21 && emu->revision < 6)) |
| 311 | outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE, emu->port + HCFG); |
| 312 | else |
| 313 | // With on-chip joystick |
| 314 | outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); |
| 315 | |
| 316 | if (enable_ir) { /* enable IR for SB Live */ |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 317 | if (emu->card_capabilities->emu1010) { |
| 318 | ; /* Disable all access to A_IOCFG for the emu1010 */ |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 319 | } else if (emu->card_capabilities->i2c_adc) { |
| 320 | ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 321 | } else if (emu->audigy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | unsigned int reg = inl(emu->port + A_IOCFG); |
| 323 | outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG); |
| 324 | udelay(500); |
| 325 | outl(reg | A_IOCFG_GPOUT1 | A_IOCFG_GPOUT2, emu->port + A_IOCFG); |
| 326 | udelay(100); |
| 327 | outl(reg, emu->port + A_IOCFG); |
| 328 | } else { |
| 329 | unsigned int reg = inl(emu->port + HCFG); |
| 330 | outl(reg | HCFG_GPOUT2, emu->port + HCFG); |
| 331 | udelay(500); |
| 332 | outl(reg | HCFG_GPOUT1 | HCFG_GPOUT2, emu->port + HCFG); |
| 333 | udelay(100); |
| 334 | outl(reg, emu->port + HCFG); |
| 335 | } |
| 336 | } |
| 337 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 338 | if (emu->card_capabilities->emu1010) { |
| 339 | ; /* Disable all access to A_IOCFG for the emu1010 */ |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 340 | } else if (emu->card_capabilities->i2c_adc) { |
| 341 | ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 342 | } else if (emu->audigy) { /* enable analog output */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | unsigned int reg = inl(emu->port + A_IOCFG); |
| 344 | outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG); |
| 345 | } |
| 346 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 347 | return 0; |
| 348 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 350 | static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu) |
| 351 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | /* |
| 353 | * Enable the audio bit |
| 354 | */ |
| 355 | outl(inl(emu->port + HCFG) | HCFG_AUDIOENABLE, emu->port + HCFG); |
| 356 | |
| 357 | /* Enable analog/digital outs on audigy */ |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 358 | if (emu->card_capabilities->emu1010) { |
| 359 | ; /* Disable all access to A_IOCFG for the emu1010 */ |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 360 | } else if (emu->card_capabilities->i2c_adc) { |
| 361 | ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 362 | } else if (emu->audigy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); |
| 364 | |
James Courtier-Dutton | e0474e5 | 2005-07-02 16:33:34 +0200 | [diff] [blame] | 365 | if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | /* Unmute Analog now. Set GPO6 to 1 for Apollo. |
| 367 | * This has to be done after init ALice3 I2SOut beyond 48KHz. |
| 368 | * So, sequence is important. */ |
| 369 | outl(inl(emu->port + A_IOCFG) | 0x0040, emu->port + A_IOCFG); |
James Courtier-Dutton | e0474e5 | 2005-07-02 16:33:34 +0200 | [diff] [blame] | 370 | } else if (emu->card_capabilities->ca0108_chip) { /* audigy2 value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | /* Unmute Analog now. */ |
| 372 | outl(inl(emu->port + A_IOCFG) | 0x0060, emu->port + A_IOCFG); |
| 373 | } else { |
| 374 | /* Disable routing from AC97 line out to Front speakers */ |
| 375 | outl(inl(emu->port + A_IOCFG) | 0x0080, emu->port + A_IOCFG); |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | #if 0 |
| 380 | { |
| 381 | unsigned int tmp; |
| 382 | /* FIXME: the following routine disables LiveDrive-II !! */ |
| 383 | // TOSLink detection |
| 384 | emu->tos_link = 0; |
| 385 | tmp = inl(emu->port + HCFG); |
| 386 | if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) { |
| 387 | outl(tmp|0x800, emu->port + HCFG); |
| 388 | udelay(50); |
| 389 | if (tmp != (inl(emu->port + HCFG) & ~0x800)) { |
| 390 | emu->tos_link = 1; |
| 391 | outl(tmp, emu->port + HCFG); |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | #endif |
| 396 | |
| 397 | snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | } |
| 399 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 400 | int snd_emu10k1_done(struct snd_emu10k1 * emu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | { |
| 402 | int ch; |
| 403 | |
| 404 | outl(0, emu->port + INTE); |
| 405 | |
| 406 | /* |
| 407 | * Shutdown the chip |
| 408 | */ |
| 409 | for (ch = 0; ch < NUM_G; ch++) |
| 410 | snd_emu10k1_ptr_write(emu, DCYSUSV, ch, 0); |
| 411 | for (ch = 0; ch < NUM_G; ch++) { |
| 412 | snd_emu10k1_ptr_write(emu, VTFT, ch, 0); |
| 413 | snd_emu10k1_ptr_write(emu, CVCF, ch, 0); |
| 414 | snd_emu10k1_ptr_write(emu, PTRX, ch, 0); |
| 415 | snd_emu10k1_ptr_write(emu, CPF, ch, 0); |
| 416 | } |
| 417 | |
| 418 | /* reset recording buffers */ |
| 419 | snd_emu10k1_ptr_write(emu, MICBS, 0, 0); |
| 420 | snd_emu10k1_ptr_write(emu, MICBA, 0, 0); |
| 421 | snd_emu10k1_ptr_write(emu, FXBS, 0, 0); |
| 422 | snd_emu10k1_ptr_write(emu, FXBA, 0, 0); |
| 423 | snd_emu10k1_ptr_write(emu, FXWC, 0, 0); |
| 424 | snd_emu10k1_ptr_write(emu, ADCBS, 0, ADCBS_BUFSIZE_NONE); |
| 425 | snd_emu10k1_ptr_write(emu, ADCBA, 0, 0); |
| 426 | snd_emu10k1_ptr_write(emu, TCBS, 0, TCBS_BUFFSIZE_16K); |
| 427 | snd_emu10k1_ptr_write(emu, TCB, 0, 0); |
| 428 | if (emu->audigy) |
| 429 | snd_emu10k1_ptr_write(emu, A_DBG, 0, A_DBG_SINGLE_STEP); |
| 430 | else |
| 431 | snd_emu10k1_ptr_write(emu, DBG, 0, EMU10K1_DBG_SINGLE_STEP); |
| 432 | |
| 433 | /* disable channel interrupt */ |
| 434 | snd_emu10k1_ptr_write(emu, CLIEL, 0, 0); |
| 435 | snd_emu10k1_ptr_write(emu, CLIEH, 0, 0); |
| 436 | snd_emu10k1_ptr_write(emu, SOLEL, 0, 0); |
| 437 | snd_emu10k1_ptr_write(emu, SOLEH, 0, 0); |
| 438 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | /* disable audio and lock cache */ |
| 440 | outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG); |
| 441 | snd_emu10k1_ptr_write(emu, PTB, 0, 0); |
| 442 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | return 0; |
| 444 | } |
| 445 | |
| 446 | /************************************************************************* |
| 447 | * ECARD functional implementation |
| 448 | *************************************************************************/ |
| 449 | |
| 450 | /* In A1 Silicon, these bits are in the HC register */ |
| 451 | #define HOOKN_BIT (1L << 12) |
| 452 | #define HANDN_BIT (1L << 11) |
| 453 | #define PULSEN_BIT (1L << 10) |
| 454 | |
| 455 | #define EC_GDI1 (1 << 13) |
| 456 | #define EC_GDI0 (1 << 14) |
| 457 | |
| 458 | #define EC_NUM_CONTROL_BITS 20 |
| 459 | |
| 460 | #define EC_AC3_DATA_SELN 0x0001L |
| 461 | #define EC_EE_DATA_SEL 0x0002L |
| 462 | #define EC_EE_CNTRL_SELN 0x0004L |
| 463 | #define EC_EECLK 0x0008L |
| 464 | #define EC_EECS 0x0010L |
| 465 | #define EC_EESDO 0x0020L |
| 466 | #define EC_TRIM_CSN 0x0040L |
| 467 | #define EC_TRIM_SCLK 0x0080L |
| 468 | #define EC_TRIM_SDATA 0x0100L |
| 469 | #define EC_TRIM_MUTEN 0x0200L |
| 470 | #define EC_ADCCAL 0x0400L |
| 471 | #define EC_ADCRSTN 0x0800L |
| 472 | #define EC_DACCAL 0x1000L |
| 473 | #define EC_DACMUTEN 0x2000L |
| 474 | #define EC_LEDN 0x4000L |
| 475 | |
| 476 | #define EC_SPDIF0_SEL_SHIFT 15 |
| 477 | #define EC_SPDIF1_SEL_SHIFT 17 |
| 478 | #define EC_SPDIF0_SEL_MASK (0x3L << EC_SPDIF0_SEL_SHIFT) |
| 479 | #define EC_SPDIF1_SEL_MASK (0x7L << EC_SPDIF1_SEL_SHIFT) |
| 480 | #define EC_SPDIF0_SELECT(_x) (((_x) << EC_SPDIF0_SEL_SHIFT) & EC_SPDIF0_SEL_MASK) |
| 481 | #define EC_SPDIF1_SELECT(_x) (((_x) << EC_SPDIF1_SEL_SHIFT) & EC_SPDIF1_SEL_MASK) |
| 482 | #define EC_CURRENT_PROM_VERSION 0x01 /* Self-explanatory. This should |
| 483 | * be incremented any time the EEPROM's |
| 484 | * format is changed. */ |
| 485 | |
| 486 | #define EC_EEPROM_SIZE 0x40 /* ECARD EEPROM has 64 16-bit words */ |
| 487 | |
| 488 | /* Addresses for special values stored in to EEPROM */ |
| 489 | #define EC_PROM_VERSION_ADDR 0x20 /* Address of the current prom version */ |
| 490 | #define EC_BOARDREV0_ADDR 0x21 /* LSW of board rev */ |
| 491 | #define EC_BOARDREV1_ADDR 0x22 /* MSW of board rev */ |
| 492 | |
| 493 | #define EC_LAST_PROMFILE_ADDR 0x2f |
| 494 | |
| 495 | #define EC_SERIALNUM_ADDR 0x30 /* First word of serial number. The |
| 496 | * can be up to 30 characters in length |
| 497 | * and is stored as a NULL-terminated |
| 498 | * ASCII string. Any unused bytes must be |
| 499 | * filled with zeros */ |
| 500 | #define EC_CHECKSUM_ADDR 0x3f /* Location at which checksum is stored */ |
| 501 | |
| 502 | |
| 503 | /* Most of this stuff is pretty self-evident. According to the hardware |
| 504 | * dudes, we need to leave the ADCCAL bit low in order to avoid a DC |
| 505 | * offset problem. Weird. |
| 506 | */ |
| 507 | #define EC_RAW_RUN_MODE (EC_DACMUTEN | EC_ADCRSTN | EC_TRIM_MUTEN | \ |
| 508 | EC_TRIM_CSN) |
| 509 | |
| 510 | |
| 511 | #define EC_DEFAULT_ADC_GAIN 0xC4C4 |
| 512 | #define EC_DEFAULT_SPDIF0_SEL 0x0 |
| 513 | #define EC_DEFAULT_SPDIF1_SEL 0x4 |
| 514 | |
| 515 | /************************************************************************** |
| 516 | * @func Clock bits into the Ecard's control latch. The Ecard uses a |
| 517 | * control latch will is loaded bit-serially by toggling the Modem control |
| 518 | * lines from function 2 on the E8010. This function hides these details |
| 519 | * and presents the illusion that we are actually writing to a distinct |
| 520 | * register. |
| 521 | */ |
| 522 | |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 523 | static void snd_emu10k1_ecard_write(struct snd_emu10k1 * emu, unsigned int value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | { |
| 525 | unsigned short count; |
| 526 | unsigned int data; |
| 527 | unsigned long hc_port; |
| 528 | unsigned int hc_value; |
| 529 | |
| 530 | hc_port = emu->port + HCFG; |
| 531 | hc_value = inl(hc_port) & ~(HOOKN_BIT | HANDN_BIT | PULSEN_BIT); |
| 532 | outl(hc_value, hc_port); |
| 533 | |
| 534 | for (count = 0; count < EC_NUM_CONTROL_BITS; count++) { |
| 535 | |
| 536 | /* Set up the value */ |
| 537 | data = ((value & 0x1) ? PULSEN_BIT : 0); |
| 538 | value >>= 1; |
| 539 | |
| 540 | outl(hc_value | data, hc_port); |
| 541 | |
| 542 | /* Clock the shift register */ |
| 543 | outl(hc_value | data | HANDN_BIT, hc_port); |
| 544 | outl(hc_value | data, hc_port); |
| 545 | } |
| 546 | |
| 547 | /* Latch the bits */ |
| 548 | outl(hc_value | HOOKN_BIT, hc_port); |
| 549 | outl(hc_value, hc_port); |
| 550 | } |
| 551 | |
| 552 | /************************************************************************** |
| 553 | * @func Set the gain of the ECARD's CS3310 Trim/gain controller. The |
| 554 | * trim value consists of a 16bit value which is composed of two |
| 555 | * 8 bit gain/trim values, one for the left channel and one for the |
| 556 | * right channel. The following table maps from the Gain/Attenuation |
| 557 | * value in decibels into the corresponding bit pattern for a single |
| 558 | * channel. |
| 559 | */ |
| 560 | |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 561 | static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | unsigned short gain) |
| 563 | { |
| 564 | unsigned int bit; |
| 565 | |
| 566 | /* Enable writing to the TRIM registers */ |
| 567 | snd_emu10k1_ecard_write(emu, emu->ecard_ctrl & ~EC_TRIM_CSN); |
| 568 | |
| 569 | /* Do it again to insure that we meet hold time requirements */ |
| 570 | snd_emu10k1_ecard_write(emu, emu->ecard_ctrl & ~EC_TRIM_CSN); |
| 571 | |
| 572 | for (bit = (1 << 15); bit; bit >>= 1) { |
| 573 | unsigned int value; |
| 574 | |
| 575 | value = emu->ecard_ctrl & ~(EC_TRIM_CSN | EC_TRIM_SDATA); |
| 576 | |
| 577 | if (gain & bit) |
| 578 | value |= EC_TRIM_SDATA; |
| 579 | |
| 580 | /* Clock the bit */ |
| 581 | snd_emu10k1_ecard_write(emu, value); |
| 582 | snd_emu10k1_ecard_write(emu, value | EC_TRIM_SCLK); |
| 583 | snd_emu10k1_ecard_write(emu, value); |
| 584 | } |
| 585 | |
| 586 | snd_emu10k1_ecard_write(emu, emu->ecard_ctrl); |
| 587 | } |
| 588 | |
Takashi Iwai | f40b689 | 2006-07-05 16:51:05 +0200 | [diff] [blame] | 589 | static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | { |
| 591 | unsigned int hc_value; |
| 592 | |
| 593 | /* Set up the initial settings */ |
| 594 | emu->ecard_ctrl = EC_RAW_RUN_MODE | |
| 595 | EC_SPDIF0_SELECT(EC_DEFAULT_SPDIF0_SEL) | |
| 596 | EC_SPDIF1_SELECT(EC_DEFAULT_SPDIF1_SEL); |
| 597 | |
| 598 | /* Step 0: Set the codec type in the hardware control register |
| 599 | * and enable audio output */ |
| 600 | hc_value = inl(emu->port + HCFG); |
| 601 | outl(hc_value | HCFG_AUDIOENABLE | HCFG_CODECFORMAT_I2S, emu->port + HCFG); |
| 602 | inl(emu->port + HCFG); |
| 603 | |
| 604 | /* Step 1: Turn off the led and deassert TRIM_CS */ |
| 605 | snd_emu10k1_ecard_write(emu, EC_ADCCAL | EC_LEDN | EC_TRIM_CSN); |
| 606 | |
| 607 | /* Step 2: Calibrate the ADC and DAC */ |
| 608 | snd_emu10k1_ecard_write(emu, EC_DACCAL | EC_LEDN | EC_TRIM_CSN); |
| 609 | |
| 610 | /* Step 3: Wait for awhile; XXX We can't get away with this |
| 611 | * under a real operating system; we'll need to block and wait that |
| 612 | * way. */ |
| 613 | snd_emu10k1_wait(emu, 48000); |
| 614 | |
| 615 | /* Step 4: Switch off the DAC and ADC calibration. Note |
| 616 | * That ADC_CAL is actually an inverted signal, so we assert |
| 617 | * it here to stop calibration. */ |
| 618 | snd_emu10k1_ecard_write(emu, EC_ADCCAL | EC_LEDN | EC_TRIM_CSN); |
| 619 | |
| 620 | /* Step 4: Switch into run mode */ |
| 621 | snd_emu10k1_ecard_write(emu, emu->ecard_ctrl); |
| 622 | |
| 623 | /* Step 5: Set the analog input gain */ |
| 624 | snd_emu10k1_ecard_setadcgain(emu, EC_DEFAULT_ADC_GAIN); |
| 625 | |
| 626 | return 0; |
| 627 | } |
| 628 | |
Takashi Iwai | f40b689 | 2006-07-05 16:51:05 +0200 | [diff] [blame] | 629 | static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) |
James Courtier-Dutton | d83c671 | 2005-10-31 10:27:41 +0000 | [diff] [blame] | 630 | { |
| 631 | unsigned long special_port; |
| 632 | unsigned int value; |
| 633 | |
| 634 | /* Special initialisation routine |
| 635 | * before the rest of the IO-Ports become active. |
| 636 | */ |
| 637 | special_port = emu->port + 0x38; |
| 638 | value = inl(special_port); |
| 639 | outl(0x00d00000, special_port); |
| 640 | value = inl(special_port); |
| 641 | outl(0x00d00001, special_port); |
| 642 | value = inl(special_port); |
| 643 | outl(0x00d0005f, special_port); |
| 644 | value = inl(special_port); |
| 645 | outl(0x00d0007f, special_port); |
| 646 | value = inl(special_port); |
| 647 | outl(0x0090007f, special_port); |
| 648 | value = inl(special_port); |
| 649 | |
James Courtier-Dutton | e2b15f8 | 2005-11-11 23:39:05 +0100 | [diff] [blame] | 650 | snd_emu10k1_ptr20_write(emu, TINA2_VOLUME, 0, 0xfefefefe); /* Defaults to 0x30303030 */ |
James Courtier-Dutton | d83c671 | 2005-10-31 10:27:41 +0000 | [diff] [blame] | 651 | return 0; |
| 652 | } |
| 653 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 654 | static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename) |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 655 | { |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 656 | int err; |
| 657 | int n, i; |
| 658 | int reg; |
| 659 | int value; |
| 660 | const struct firmware *fw_entry; |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 661 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 662 | if ((err = request_firmware(&fw_entry, filename, &emu->pci->dev)) != 0) { |
| 663 | snd_printk(KERN_ERR "firmware: %s not found. Err=%d\n",filename, err); |
| 664 | return err; |
| 665 | } |
Takashi Iwai | bbb5355 | 2006-10-05 16:21:19 +0200 | [diff] [blame] | 666 | snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size); |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 667 | #if 0 |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 668 | if (fw_entry->size != 0x133a4) { |
| 669 | snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename); |
| 670 | return -EINVAL; |
| 671 | } |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 672 | #endif |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 673 | |
| 674 | /* The FPGA is a Xilinx Spartan IIE XC2S50E */ |
| 675 | /* GPIO7 -> FPGA PGMN |
| 676 | * GPIO6 -> FPGA CCLK |
| 677 | * GPIO5 -> FPGA DIN |
| 678 | * FPGA CONFIG OFF -> FPGA PGMN |
| 679 | */ |
| 680 | outl(0x00, emu->port + A_IOCFG); /* Set PGMN low for 1uS. */ |
| 681 | udelay(1); |
| 682 | outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */ |
| 683 | udelay(100); /* Allow FPGA memory to clean */ |
| 684 | for(n = 0; n < fw_entry->size; n++) { |
| 685 | value=fw_entry->data[n]; |
| 686 | for(i = 0; i < 8; i++) { |
| 687 | reg = 0x80; |
| 688 | if (value & 0x1) |
| 689 | reg = reg | 0x20; |
| 690 | value = value >> 1; |
| 691 | outl(reg, emu->port + A_IOCFG); |
| 692 | outl(reg | 0x40, emu->port + A_IOCFG); |
| 693 | } |
| 694 | } |
| 695 | /* After programming, set GPIO bit 4 high again. */ |
| 696 | outl(0x10, emu->port + A_IOCFG); |
| 697 | |
| 698 | |
| 699 | release_firmware(fw_entry); |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 700 | return 0; |
| 701 | } |
| 702 | |
Pavel Hofman | 13d4570 | 2007-06-11 12:21:20 +0200 | [diff] [blame] | 703 | /* |
| 704 | * EMU-1010 - details found out from this driver, official MS Win drivers, |
| 705 | * testing the card: |
| 706 | * |
| 707 | * Audigy2 (aka Alice2): |
| 708 | * --------------------- |
| 709 | * * communication over PCI |
| 710 | * * conversion of 32-bit data coming over EMU32 links from HANA FPGA |
| 711 | * to 2 x 16-bit, using internal DSP instructions |
| 712 | * * slave mode, clock supplied by HANA |
| 713 | * * linked to HANA using: |
| 714 | * 32 x 32-bit serial EMU32 output channels |
| 715 | * 16 x EMU32 input channels |
| 716 | * (?) x I2S I/O channels (?) |
| 717 | * |
| 718 | * FPGA (aka HANA): |
| 719 | * --------------- |
| 720 | * * provides all (?) physical inputs and outputs of the card |
| 721 | * (ADC, DAC, SPDIF I/O, ADAT I/O, etc.) |
| 722 | * * provides clock signal for the card and Alice2 |
| 723 | * * two crystals - for 44.1kHz and 48kHz multiples |
| 724 | * * provides internal routing of signal sources to signal destinations |
| 725 | * * inputs/outputs to Alice2 - see above |
| 726 | * |
| 727 | * Current status of the driver: |
| 728 | * ---------------------------- |
| 729 | * * only 44.1/48kHz supported (the MS Win driver supports up to 192 kHz) |
| 730 | * * PCM device nb. 2: |
| 731 | * 16 x 16-bit playback - snd_emu10k1_fx8010_playback_ops |
| 732 | * 16 x 32-bit capture - snd_emu10k1_capture_efx_ops |
| 733 | */ |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 734 | static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 735 | { |
| 736 | unsigned int i; |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 737 | int tmp,tmp2; |
| 738 | int reg; |
| 739 | int err; |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 740 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 741 | snd_printk(KERN_INFO "emu1010: Special config.\n"); |
| 742 | /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, |
| 743 | * Lock Sound Memory Cache, Lock Tank Memory Cache, |
| 744 | * Mute all codecs. |
| 745 | */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 746 | outl(0x0005a00c, emu->port + HCFG); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 747 | /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, |
| 748 | * Lock Tank Memory Cache, |
| 749 | * Mute all codecs. |
| 750 | */ |
| 751 | outl(0x0005a004, emu->port + HCFG); |
| 752 | /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, |
| 753 | * Mute all codecs. |
| 754 | */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 755 | outl(0x0005a000, emu->port + HCFG); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 756 | /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, |
| 757 | * Mute all codecs. |
| 758 | */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 759 | outl(0x0005a000, emu->port + HCFG); |
| 760 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 761 | /* Disable 48Volt power to Audio Dock */ |
| 762 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 763 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 764 | /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ |
| 765 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); |
| 766 | snd_printdd("reg1=0x%x\n",reg); |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 767 | if ((reg & 0x1f) == 0x15) { |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 768 | /* FPGA netlist already present so clear it */ |
| 769 | /* Return to programming mode */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 770 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 771 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02 ); |
| 772 | } |
| 773 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); |
| 774 | snd_printdd("reg2=0x%x\n",reg); |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 775 | if ((reg & 0x1f) == 0x15) { |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 776 | /* FPGA failed to return to programming mode */ |
| 777 | return -ENODEV; |
| 778 | } |
| 779 | snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 780 | if (emu->card_capabilities->emu1010 == 1) { |
| 781 | if ((err = snd_emu1010_load_firmware(emu, HANA_FILENAME)) != 0) { |
| 782 | snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", HANA_FILENAME); |
| 783 | return err; |
| 784 | } |
| 785 | } else if (emu->card_capabilities->emu1010 == 2) { |
| 786 | if ((err = snd_emu1010_load_firmware(emu, EMU1010B_FILENAME)) != 0) { |
| 787 | snd_printk(KERN_INFO "emu1010: Loading Firmware file %s failed\n", EMU1010B_FILENAME); |
| 788 | return err; |
| 789 | } |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ |
| 793 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 794 | if ((reg & 0x1f) != 0x15) { |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 795 | /* FPGA failed to be programmed */ |
| 796 | snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg); |
| 797 | return -ENODEV; |
| 798 | } |
| 799 | |
| 800 | snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n"); |
| 801 | snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp ); |
| 802 | snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2 ); |
| 803 | snd_printk("Hana ver:%d.%d\n",tmp ,tmp2); |
| 804 | /* Enable 48Volt power to Audio Dock */ |
| 805 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON ); |
| 806 | |
| 807 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); |
| 808 | snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); |
| 809 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); |
| 810 | snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); |
| 811 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); |
| 812 | /* ADAT input. */ |
| 813 | snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x01 ); |
James Courtier-Dutton | 9148cc5 | 2006-10-09 23:08:00 +0100 | [diff] [blame] | 814 | snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp ); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 815 | /* Set no attenuation on Audio Dock pads. */ |
James Courtier-Dutton | 9148cc5 | 2006-10-09 23:08:00 +0100 | [diff] [blame] | 816 | snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 ); |
| 817 | emu->emu1010.adc_pads = 0x00; |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 818 | snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); |
| 819 | /* Unmute Audio dock DACs, Headphone source DAC-4. */ |
| 820 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); |
| 821 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); |
James Courtier-Dutton | 9148cc5 | 2006-10-09 23:08:00 +0100 | [diff] [blame] | 822 | snd_emu1010_fpga_read(emu, EMU_HANA_DAC_PADS, &tmp ); |
| 823 | /* DAC PADs. */ |
| 824 | snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, 0x0f ); |
| 825 | emu->emu1010.dac_pads = 0x0f; |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 826 | snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); |
| 827 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); |
| 828 | snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); |
| 829 | /* SPDIF Format. Set Consumer mode, 24bit, copy enable */ |
| 830 | snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); |
| 831 | /* MIDI routing */ |
James Courtier-Dutton | 9148cc5 | 2006-10-09 23:08:00 +0100 | [diff] [blame] | 832 | snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 833 | /* Unknown. */ |
James Courtier-Dutton | 9148cc5 | 2006-10-09 23:08:00 +0100 | [diff] [blame] | 834 | snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 835 | /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); // IRQ Enable: All on */ |
| 836 | /* IRQ Enable: All off */ |
| 837 | snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00 ); |
| 838 | |
| 839 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); |
| 840 | snd_printk(KERN_INFO "emu1010: Card options3=0x%x\n",reg); |
| 841 | /* Default WCLK set to 48kHz. */ |
| 842 | snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00 ); |
| 843 | /* Word Clock source, Internal 48kHz x1 */ |
| 844 | snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); |
| 845 | //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); |
| 846 | /* Audio Dock LEDs. */ |
| 847 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); |
| 848 | |
| 849 | #if 0 |
| 850 | /* For 96kHz */ |
| 851 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 852 | EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1); |
| 853 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 854 | EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1); |
| 855 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 856 | EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT2); |
| 857 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 858 | EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT2); |
| 859 | #endif |
| 860 | #if 0 |
| 861 | /* For 192kHz */ |
| 862 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 863 | EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1); |
| 864 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 865 | EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1); |
| 866 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 867 | EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2); |
| 868 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 869 | EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_RIGHT2); |
| 870 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 871 | EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT3); |
| 872 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 873 | EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT3); |
| 874 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 875 | EMU_DST_ALICE2_EMU32_6, EMU_SRC_HAMOA_ADC_LEFT4); |
| 876 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 877 | EMU_DST_ALICE2_EMU32_7, EMU_SRC_HAMOA_ADC_RIGHT4); |
| 878 | #endif |
| 879 | #if 1 |
| 880 | /* For 48kHz */ |
| 881 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 882 | EMU_DST_ALICE2_EMU32_0, EMU_SRC_DOCK_MIC_A1); |
| 883 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 884 | EMU_DST_ALICE2_EMU32_1, EMU_SRC_DOCK_MIC_B1); |
| 885 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 886 | EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2); |
| 887 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 888 | EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_LEFT2); |
| 889 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 890 | EMU_DST_ALICE2_EMU32_4, EMU_SRC_DOCK_ADC1_LEFT1); |
| 891 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 892 | EMU_DST_ALICE2_EMU32_5, EMU_SRC_DOCK_ADC1_RIGHT1); |
| 893 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 894 | EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1); |
| 895 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 896 | EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1); |
Pavel Hofman | 13d4570 | 2007-06-11 12:21:20 +0200 | [diff] [blame] | 897 | /* Pavel Hofman - setting defaults for 8 more capture channels |
| 898 | * Defaults only, users will set their own values anyways, let's |
| 899 | * just copy/paste. |
| 900 | */ |
| 901 | |
| 902 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 903 | EMU_DST_ALICE2_EMU32_8, EMU_SRC_DOCK_MIC_A1); |
| 904 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 905 | EMU_DST_ALICE2_EMU32_9, EMU_SRC_DOCK_MIC_B1); |
| 906 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 907 | EMU_DST_ALICE2_EMU32_A, EMU_SRC_HAMOA_ADC_LEFT2); |
| 908 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 909 | EMU_DST_ALICE2_EMU32_B, EMU_SRC_HAMOA_ADC_LEFT2); |
| 910 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 911 | EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_ADC1_LEFT1); |
| 912 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 913 | EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_ADC1_RIGHT1); |
| 914 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 915 | EMU_DST_ALICE2_EMU32_E, EMU_SRC_DOCK_ADC2_LEFT1); |
| 916 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 917 | EMU_DST_ALICE2_EMU32_F, EMU_SRC_DOCK_ADC2_RIGHT1); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 918 | #endif |
| 919 | #if 0 |
| 920 | /* Original */ |
| 921 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 922 | EMU_DST_ALICE2_EMU32_4, EMU_SRC_HANA_ADAT); |
| 923 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 924 | EMU_DST_ALICE2_EMU32_5, EMU_SRC_HANA_ADAT + 1); |
| 925 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 926 | EMU_DST_ALICE2_EMU32_6, EMU_SRC_HANA_ADAT + 2); |
| 927 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 928 | EMU_DST_ALICE2_EMU32_7, EMU_SRC_HANA_ADAT + 3); |
| 929 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 930 | EMU_DST_ALICE2_EMU32_8, EMU_SRC_HANA_ADAT + 4); |
| 931 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 932 | EMU_DST_ALICE2_EMU32_9, EMU_SRC_HANA_ADAT + 5); |
| 933 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 934 | EMU_DST_ALICE2_EMU32_A, EMU_SRC_HANA_ADAT + 6); |
| 935 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 936 | EMU_DST_ALICE2_EMU32_B, EMU_SRC_HANA_ADAT + 7); |
| 937 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 938 | EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_MIC_A1); |
| 939 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 940 | EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_MIC_B1); |
| 941 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 942 | EMU_DST_ALICE2_EMU32_E, EMU_SRC_HAMOA_ADC_LEFT2); |
| 943 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 944 | EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2); |
| 945 | #endif |
| 946 | for (i = 0;i < 0x20; i++ ) { |
| 947 | /* AudioDock Elink <- Silence */ |
| 948 | snd_emu1010_fpga_link_dst_src_write(emu, 0x0100+i, EMU_SRC_SILENCE); |
| 949 | } |
| 950 | for (i = 0;i < 4; i++) { |
| 951 | /* Hana SPDIF Out <- Silence */ |
| 952 | snd_emu1010_fpga_link_dst_src_write(emu, 0x0200+i, EMU_SRC_SILENCE); |
| 953 | } |
| 954 | for (i = 0;i < 7; i++) { |
| 955 | /* Hamoa DAC <- Silence */ |
| 956 | snd_emu1010_fpga_link_dst_src_write(emu, 0x0300+i, EMU_SRC_SILENCE); |
| 957 | } |
| 958 | for (i = 0;i < 7; i++) { |
| 959 | /* Hana ADAT Out <- Silence */ |
| 960 | snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE); |
| 961 | } |
| 962 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 963 | EMU_DST_ALICE_I2S0_LEFT, EMU_SRC_DOCK_ADC1_LEFT1); |
| 964 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 965 | EMU_DST_ALICE_I2S0_RIGHT, EMU_SRC_DOCK_ADC1_RIGHT1); |
| 966 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 967 | EMU_DST_ALICE_I2S1_LEFT, EMU_SRC_DOCK_ADC2_LEFT1); |
| 968 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 969 | EMU_DST_ALICE_I2S1_RIGHT, EMU_SRC_DOCK_ADC2_RIGHT1); |
| 970 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 971 | EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1); |
| 972 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 973 | EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1); |
| 974 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01 ); // Unmute all |
| 975 | |
| 976 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp ); |
| 977 | |
| 978 | /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, |
| 979 | * Lock Sound Memory Cache, Lock Tank Memory Cache, |
| 980 | * Mute all codecs. |
| 981 | */ |
| 982 | outl(0x0000a000, emu->port + HCFG); |
| 983 | /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, |
| 984 | * Lock Sound Memory Cache, Lock Tank Memory Cache, |
| 985 | * Un-Mute all codecs. |
| 986 | */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 987 | outl(0x0000a001, emu->port + HCFG); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 988 | |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 989 | /* Initial boot complete. Now patches */ |
| 990 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 991 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp ); |
James Courtier-Dutton | 9148cc5 | 2006-10-09 23:08:00 +0100 | [diff] [blame] | 992 | snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ |
| 993 | snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ |
| 994 | snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ |
| 995 | snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 996 | snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); |
| 997 | snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif (or 0x11 for aes/ebu) */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 998 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 999 | /* Delay to allow Audio Dock to settle */ |
| 1000 | msleep(100); |
| 1001 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */ |
| 1002 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); /* OPTIONS: Which cards are attached to the EMU */ |
| 1003 | /* FIXME: The loading of this should be able to happen any time, |
| 1004 | * as the user can plug/unplug it at any time |
| 1005 | */ |
| 1006 | if (reg & (EMU_HANA_OPTION_DOCK_ONLINE | EMU_HANA_OPTION_DOCK_OFFLINE) ) { |
| 1007 | /* Audio Dock attached */ |
| 1008 | /* Return to Audio Dock programming mode */ |
| 1009 | snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); |
| 1010 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 1011 | if (emu->card_capabilities->emu1010 == 1) { |
| 1012 | if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) { |
| 1013 | return err; |
| 1014 | } |
| 1015 | } else if (emu->card_capabilities->emu1010 == 2) { |
| 1016 | if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { |
| 1017 | return err; |
| 1018 | } |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1019 | } |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 1020 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1021 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); |
| 1022 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ® ); |
| 1023 | snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); |
| 1024 | /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ |
| 1025 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); |
| 1026 | snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 1027 | if ((reg & 0x1f) != 0x15) { |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1028 | /* FPGA failed to be programmed */ |
| 1029 | snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); |
| 1030 | return 0; |
| 1031 | return -ENODEV; |
| 1032 | } |
James Courtier-Dutton | 9148cc5 | 2006-10-09 23:08:00 +0100 | [diff] [blame] | 1033 | snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); |
| 1034 | snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp ); |
| 1035 | snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2 ); |
| 1036 | snd_printk("Audio Dock ver:%d.%d\n",tmp ,tmp2); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1037 | } |
| 1038 | #if 0 |
| 1039 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1040 | EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32B + 2); /* ALICE2 bus 0xa2 */ |
| 1041 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1042 | EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32B + 3); /* ALICE2 bus 0xa3 */ |
| 1043 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1044 | EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 2); /* ALICE2 bus 0xb2 */ |
| 1045 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1046 | EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 3); /* ALICE2 bus 0xb3 */ |
| 1047 | #endif |
| 1048 | /* Default outputs */ |
| 1049 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1050 | EMU_DST_DOCK_DAC1_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ |
| 1051 | emu->emu1010.output_source[0] = 21; |
| 1052 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1053 | EMU_DST_DOCK_DAC1_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); |
| 1054 | emu->emu1010.output_source[1] = 22; |
| 1055 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1056 | EMU_DST_DOCK_DAC2_LEFT1, EMU_SRC_ALICE_EMU32A + 2); |
| 1057 | emu->emu1010.output_source[2] = 23; |
| 1058 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1059 | EMU_DST_DOCK_DAC2_RIGHT1, EMU_SRC_ALICE_EMU32A + 3); |
| 1060 | emu->emu1010.output_source[3] = 24; |
| 1061 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1062 | EMU_DST_DOCK_DAC3_LEFT1, EMU_SRC_ALICE_EMU32A + 4); |
| 1063 | emu->emu1010.output_source[4] = 25; |
| 1064 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1065 | EMU_DST_DOCK_DAC3_RIGHT1, EMU_SRC_ALICE_EMU32A + 5); |
| 1066 | emu->emu1010.output_source[5] = 26; |
| 1067 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1068 | EMU_DST_DOCK_DAC4_LEFT1, EMU_SRC_ALICE_EMU32A + 6); |
| 1069 | emu->emu1010.output_source[6] = 27; |
| 1070 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1071 | EMU_DST_DOCK_DAC4_RIGHT1, EMU_SRC_ALICE_EMU32A + 7); |
| 1072 | emu->emu1010.output_source[7] = 28; |
| 1073 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1074 | EMU_DST_DOCK_PHONES_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ |
| 1075 | emu->emu1010.output_source[8] = 21; |
| 1076 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1077 | EMU_DST_DOCK_PHONES_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); |
| 1078 | emu->emu1010.output_source[9] = 22; |
| 1079 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1080 | EMU_DST_DOCK_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ |
| 1081 | emu->emu1010.output_source[10] = 21; |
| 1082 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1083 | EMU_DST_DOCK_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); |
| 1084 | emu->emu1010.output_source[11] = 22; |
| 1085 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1086 | EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ |
| 1087 | emu->emu1010.output_source[12] = 21; |
| 1088 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1089 | EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); |
| 1090 | emu->emu1010.output_source[13] = 22; |
| 1091 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1092 | EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ |
| 1093 | emu->emu1010.output_source[14] = 21; |
| 1094 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1095 | EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32A + 1); |
| 1096 | emu->emu1010.output_source[15] = 22; |
| 1097 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1098 | EMU_DST_HANA_ADAT, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */ |
| 1099 | emu->emu1010.output_source[16] = 21; |
| 1100 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1101 | EMU_DST_HANA_ADAT + 1, EMU_SRC_ALICE_EMU32A + 1); |
| 1102 | emu->emu1010.output_source[17] = 22; |
| 1103 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1104 | EMU_DST_HANA_ADAT + 2, EMU_SRC_ALICE_EMU32A + 2); |
| 1105 | emu->emu1010.output_source[18] = 23; |
| 1106 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1107 | EMU_DST_HANA_ADAT + 3, EMU_SRC_ALICE_EMU32A + 3); |
| 1108 | emu->emu1010.output_source[19] = 24; |
| 1109 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1110 | EMU_DST_HANA_ADAT + 4, EMU_SRC_ALICE_EMU32A + 4); |
| 1111 | emu->emu1010.output_source[20] = 25; |
| 1112 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1113 | EMU_DST_HANA_ADAT + 5, EMU_SRC_ALICE_EMU32A + 5); |
| 1114 | emu->emu1010.output_source[21] = 26; |
| 1115 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1116 | EMU_DST_HANA_ADAT + 6, EMU_SRC_ALICE_EMU32A + 6); |
| 1117 | emu->emu1010.output_source[22] = 27; |
| 1118 | snd_emu1010_fpga_link_dst_src_write(emu, |
| 1119 | EMU_DST_HANA_ADAT + 7, EMU_SRC_ALICE_EMU32A + 7); |
| 1120 | emu->emu1010.output_source[23] = 28; |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 1121 | |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1122 | /* TEMP: Select SPDIF in/out */ |
| 1123 | snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */ |
| 1124 | |
| 1125 | /* TEMP: Select 48kHz SPDIF out */ |
| 1126 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */ |
| 1127 | snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */ |
| 1128 | /* Word Clock source, Internal 48kHz x1 */ |
| 1129 | snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); |
| 1130 | //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); |
James Courtier-Dutton | b0dbdae | 2006-10-10 18:08:45 +0100 | [diff] [blame] | 1131 | emu->emu1010.internal_clock = 1; /* 48000 */ |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1132 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);/* Set LEDs on Audio Dock */ |
| 1133 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */ |
| 1134 | //snd_emu1010_fpga_write(emu, 0x7, 0x0); /* Mute all */ |
| 1135 | //snd_emu1010_fpga_write(emu, 0x7, 0x1); /* Unmute all */ |
| 1136 | //snd_emu1010_fpga_write(emu, 0xe, 0x12); /* Set LEDs on Audio Dock */ |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 1137 | |
| 1138 | return 0; |
| 1139 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | /* |
| 1141 | * Create the EMU10K1 instance |
| 1142 | */ |
| 1143 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1144 | #ifdef CONFIG_PM |
| 1145 | static int alloc_pm_buffer(struct snd_emu10k1 *emu); |
| 1146 | static void free_pm_buffer(struct snd_emu10k1 *emu); |
| 1147 | #endif |
| 1148 | |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1149 | static int snd_emu10k1_free(struct snd_emu10k1 *emu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | { |
| 1151 | if (emu->port) { /* avoid access to already used hardware */ |
| 1152 | snd_emu10k1_fx8010_tram_setup(emu, 0); |
| 1153 | snd_emu10k1_done(emu); |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1154 | /* remove reserved page */ |
| 1155 | if (emu->reserved_page) { |
| 1156 | snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page); |
| 1157 | emu->reserved_page = NULL; |
| 1158 | } |
| 1159 | snd_emu10k1_free_efx(emu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1160 | } |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1161 | if (emu->card_capabilities->emu1010) { |
| 1162 | /* Disable 48Volt power to Audio Dock */ |
| 1163 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); |
| 1164 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | if (emu->memhdr) |
| 1166 | snd_util_memhdr_free(emu->memhdr); |
| 1167 | if (emu->silent_page.area) |
| 1168 | snd_dma_free_pages(&emu->silent_page); |
| 1169 | if (emu->ptb_pages.area) |
| 1170 | snd_dma_free_pages(&emu->ptb_pages); |
| 1171 | vfree(emu->page_ptr_table); |
| 1172 | vfree(emu->page_addr_table); |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1173 | #ifdef CONFIG_PM |
| 1174 | free_pm_buffer(emu); |
| 1175 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | if (emu->irq >= 0) |
Takashi Iwai | 437a5a4 | 2006-11-21 12:14:23 +0100 | [diff] [blame] | 1177 | free_irq(emu->irq, emu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | if (emu->port) |
| 1179 | pci_release_regions(emu->pci); |
Lee Revell | 2b637da | 2005-03-30 13:51:18 +0200 | [diff] [blame] | 1180 | if (emu->card_capabilities->ca0151_chip) /* P16V */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | snd_p16v_free(emu); |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1182 | pci_disable_device(emu->pci); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | kfree(emu); |
| 1184 | return 0; |
| 1185 | } |
| 1186 | |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1187 | static int snd_emu10k1_dev_free(struct snd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1188 | { |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1189 | struct snd_emu10k1 *emu = device->device_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | return snd_emu10k1_free(emu); |
| 1191 | } |
| 1192 | |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1193 | static struct snd_emu_chip_details emu_chip_details[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1194 | /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ |
James Courtier-Dutton | 88dc0e5 | 2005-07-03 12:54:29 +0200 | [diff] [blame] | 1195 | /* Tested by James@superbug.co.uk 3rd July 2005 */ |
James Courtier-Dutton | 54efc96 | 2005-12-22 12:58:41 +0100 | [diff] [blame] | 1196 | /* DSP: CA0108-IAT |
| 1197 | * DAC: CS4382-KQ |
| 1198 | * ADC: Philips 1361T |
| 1199 | * AC97: STAC9750 |
| 1200 | * CA0151: None |
| 1201 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, |
| 1203 | .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1204 | .id = "Audigy2", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | .emu10k2_chip = 1, |
| 1206 | .ca0108_chip = 1, |
Peter Zubaj | 2668907 | 2005-04-01 11:15:07 +0200 | [diff] [blame] | 1207 | .spk71 = 1, |
| 1208 | .ac97_chip = 1} , |
James Courtier-Dutton | 21fddde | 2006-04-09 17:36:39 +0100 | [diff] [blame] | 1209 | /* Audigy4 (Not PRO) SB0610 */ |
| 1210 | /* Tested by James@superbug.co.uk 4th April 2006 */ |
| 1211 | /* A_IOCFG bits |
| 1212 | * Output |
| 1213 | * 0: ? |
| 1214 | * 1: ? |
| 1215 | * 2: ? |
| 1216 | * 3: 0 - Digital Out, 1 - Line in |
| 1217 | * 4: ? |
| 1218 | * 5: ? |
| 1219 | * 6: ? |
| 1220 | * 7: ? |
| 1221 | * Input |
| 1222 | * 8: ? |
| 1223 | * 9: ? |
| 1224 | * A: Green jack sense (Front) |
| 1225 | * B: ? |
| 1226 | * C: Black jack sense (Rear/Side Right) |
| 1227 | * D: Yellow jack sense (Center/LFE/Side Left) |
| 1228 | * E: ? |
| 1229 | * F: ? |
| 1230 | * |
| 1231 | * Digital Out/Line in switch using A_IOCFG bit 3 (0x08) |
| 1232 | * 0 - Digital Out |
| 1233 | * 1 - Line in |
| 1234 | */ |
| 1235 | /* Mic input not tested. |
| 1236 | * Analog CD input not tested |
| 1237 | * Digital Out not tested. |
| 1238 | * Line in working. |
| 1239 | * Audio output 5.1 working. Side outputs not working. |
| 1240 | */ |
| 1241 | /* DSP: CA10300-IAT LF |
| 1242 | * DAC: Cirrus Logic CS4382-KQZ |
| 1243 | * ADC: Philips 1361T |
| 1244 | * AC97: Sigmatel STAC9750 |
| 1245 | * CA0151: None |
| 1246 | */ |
| 1247 | {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10211102, |
| 1248 | .driver = "Audigy2", .name = "Audigy 4 [SB0610]", |
| 1249 | .id = "Audigy2", |
| 1250 | .emu10k2_chip = 1, |
| 1251 | .ca0108_chip = 1, |
| 1252 | .spk71 = 1, |
| 1253 | .adc_1361t = 1, /* 24 bit capture instead of 16bit */ |
| 1254 | .ac97_chip = 1} , |
James Courtier-Dutton | d83c671 | 2005-10-31 10:27:41 +0000 | [diff] [blame] | 1255 | /* Audigy 2 ZS Notebook Cardbus card.*/ |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 1256 | /* Tested by James@superbug.co.uk 6th November 2006 */ |
James Courtier-Dutton | f951fd3 | 2005-12-22 13:05:23 +0100 | [diff] [blame] | 1257 | /* Audio output 7.1/Headphones working. |
| 1258 | * Digital output working. (AC3 not checked, only PCM) |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 1259 | * Audio Mic/Line inputs working. |
| 1260 | * Digital input not tested. |
James Courtier-Dutton | f951fd3 | 2005-12-22 13:05:23 +0100 | [diff] [blame] | 1261 | */ |
James Courtier-Dutton | 21fddde | 2006-04-09 17:36:39 +0100 | [diff] [blame] | 1262 | /* DSP: Tina2 |
James Courtier-Dutton | f951fd3 | 2005-12-22 13:05:23 +0100 | [diff] [blame] | 1263 | * DAC: Wolfson WM8768/WM8568 |
| 1264 | * ADC: Wolfson WM8775 |
| 1265 | * AC97: None |
| 1266 | * CA0151: None |
| 1267 | */ |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 1268 | /* Tested by James@superbug.co.uk 4th April 2006 */ |
| 1269 | /* A_IOCFG bits |
| 1270 | * Output |
| 1271 | * 0: Not Used |
| 1272 | * 1: 0 = Mute all the 7.1 channel out. 1 = unmute. |
| 1273 | * 2: Analog input 0 = line in, 1 = mic in |
| 1274 | * 3: Not Used |
| 1275 | * 4: Digital output 0 = off, 1 = on. |
| 1276 | * 5: Not Used |
| 1277 | * 6: Not Used |
| 1278 | * 7: Not Used |
| 1279 | * Input |
| 1280 | * All bits 1 (0x3fxx) means nothing plugged in. |
| 1281 | * 8-9: 0 = Line in/Mic, 2 = Optical in, 3 = Nothing. |
| 1282 | * A-B: 0 = Headphones, 2 = Optical out, 3 = Nothing. |
| 1283 | * C-D: 2 = Front/Rear/etc, 3 = nothing. |
| 1284 | * E-F: Always 0 |
| 1285 | * |
| 1286 | */ |
James Courtier-Dutton | d83c671 | 2005-10-31 10:27:41 +0000 | [diff] [blame] | 1287 | {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, |
| 1288 | .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", |
| 1289 | .id = "Audigy2", |
| 1290 | .emu10k2_chip = 1, |
| 1291 | .ca0108_chip = 1, |
| 1292 | .ca_cardbus_chip = 1, |
James Courtier-Dutton | 27fe864 | 2005-12-21 15:06:08 +0100 | [diff] [blame] | 1293 | .spi_dac = 1, |
James Courtier-Dutton | 184c1e2 | 2006-12-06 15:58:02 +0000 | [diff] [blame] | 1294 | .i2c_adc = 1, |
James Courtier-Dutton | d83c671 | 2005-10-31 10:27:41 +0000 | [diff] [blame] | 1295 | .spk71 = 1} , |
James Courtier-Dutton | 82c8c74 | 2007-04-19 11:14:41 +0100 | [diff] [blame] | 1296 | {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102, |
| 1297 | .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]", |
| 1298 | .id = "EMU1010", |
| 1299 | .emu10k2_chip = 1, |
| 1300 | .ca0108_chip = 1, |
| 1301 | .ca_cardbus_chip = 1, |
| 1302 | .spi_dac = 1, |
| 1303 | .i2c_adc = 1, |
| 1304 | .spk71 = 1} , |
James Courtier-Dutton | 3663d84 | 2007-07-14 02:18:26 +0100 | [diff] [blame^] | 1305 | {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102, |
| 1306 | .driver = "Audigy2", .name = "E-mu 1010b PCI [MAEM????]", |
| 1307 | .id = "EMU1010", |
| 1308 | .emu10k2_chip = 1, |
| 1309 | .ca0108_chip = 1, |
| 1310 | .spk71 = 1 , |
| 1311 | .emu1010 = 2} , |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | {.vendor = 0x1102, .device = 0x0008, |
| 1313 | .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1314 | .id = "Audigy2", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | .emu10k2_chip = 1, |
Peter Zubaj | 2668907 | 2005-04-01 11:15:07 +0200 | [diff] [blame] | 1316 | .ca0108_chip = 1, |
| 1317 | .ac97_chip = 1} , |
James Courtier-Dutton | 7c1d549 | 2005-07-10 11:50:36 +0200 | [diff] [blame] | 1318 | /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */ |
| 1319 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1320 | .driver = "Audigy2", .name = "E-mu 1010 [4001]", |
| 1321 | .id = "EMU1010", |
James Courtier-Dutton | 7c1d549 | 2005-07-10 11:50:36 +0200 | [diff] [blame] | 1322 | .emu10k2_chip = 1, |
| 1323 | .ca0102_chip = 1, |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1324 | .spk71 = 1, |
| 1325 | .emu1010 = 1} , |
James Courtier-Dutton | 88dc0e5 | 2005-07-03 12:54:29 +0200 | [diff] [blame] | 1326 | /* Tested by James@superbug.co.uk 3rd July 2005 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, |
| 1328 | .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1329 | .id = "Audigy2", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | .emu10k2_chip = 1, |
| 1331 | .ca0102_chip = 1, |
| 1332 | .ca0151_chip = 1, |
| 1333 | .spk71 = 1, |
| 1334 | .spdif_bug = 1, |
| 1335 | .ac97_chip = 1} , |
Lee Revell | f6f8bb6 | 2005-11-07 14:59:19 +0100 | [diff] [blame] | 1336 | /* Tested by shane-alsa@cm.nu 5th Nov 2005 */ |
James Courtier-Dutton | 5b0e498 | 2006-04-09 22:45:58 +0200 | [diff] [blame] | 1337 | /* The 0x20061102 does have SB0350 written on it |
| 1338 | * Just like 0x20021102 |
| 1339 | */ |
Lee Revell | f6f8bb6 | 2005-11-07 14:59:19 +0100 | [diff] [blame] | 1340 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102, |
James Courtier-Dutton | 5b0e498 | 2006-04-09 22:45:58 +0200 | [diff] [blame] | 1341 | .driver = "Audigy2", .name = "Audigy 2 [SB0350b]", |
Lee Revell | f6f8bb6 | 2005-11-07 14:59:19 +0100 | [diff] [blame] | 1342 | .id = "Audigy2", |
| 1343 | .emu10k2_chip = 1, |
| 1344 | .ca0102_chip = 1, |
| 1345 | .ca0151_chip = 1, |
| 1346 | .spk71 = 1, |
| 1347 | .spdif_bug = 1, |
| 1348 | .ac97_chip = 1} , |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1349 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, |
| 1350 | .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1351 | .id = "Audigy2", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1352 | .emu10k2_chip = 1, |
| 1353 | .ca0102_chip = 1, |
| 1354 | .ca0151_chip = 1, |
| 1355 | .spk71 = 1, |
| 1356 | .spdif_bug = 1, |
| 1357 | .ac97_chip = 1} , |
| 1358 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, |
| 1359 | .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1360 | .id = "Audigy2", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | .emu10k2_chip = 1, |
| 1362 | .ca0102_chip = 1, |
| 1363 | .ca0151_chip = 1, |
| 1364 | .spk71 = 1, |
| 1365 | .spdif_bug = 1, |
| 1366 | .ac97_chip = 1} , |
James Courtier-Dutton | 54efc96 | 2005-12-22 12:58:41 +0100 | [diff] [blame] | 1367 | /* Audigy 2 */ |
| 1368 | /* Tested by James@superbug.co.uk 3rd July 2005 */ |
| 1369 | /* DSP: CA0102-IAT |
| 1370 | * DAC: CS4382-KQ |
| 1371 | * ADC: Philips 1361T |
| 1372 | * AC97: STAC9721 |
| 1373 | * CA0151: Yes |
| 1374 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, |
| 1376 | .driver = "Audigy2", .name = "Audigy 2 [SB0240]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1377 | .id = "Audigy2", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1378 | .emu10k2_chip = 1, |
| 1379 | .ca0102_chip = 1, |
| 1380 | .ca0151_chip = 1, |
| 1381 | .spk71 = 1, |
| 1382 | .spdif_bug = 1, |
James Courtier-Dutton | 11b3a75 | 2006-07-08 16:39:30 +0100 | [diff] [blame] | 1383 | .adc_1361t = 1, /* 24 bit capture instead of 16bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | .ac97_chip = 1} , |
| 1385 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, |
| 1386 | .driver = "Audigy2", .name = "Audigy 2 EX [1005]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1387 | .id = "Audigy2", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | .emu10k2_chip = 1, |
| 1389 | .ca0102_chip = 1, |
| 1390 | .ca0151_chip = 1, |
Lee Revell | 2f020aa | 2005-11-07 14:54:24 +0100 | [diff] [blame] | 1391 | .spk71 = 1, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | .spdif_bug = 1} , |
James Courtier-Dutton | 264f957 | 2006-07-30 17:17:59 +0100 | [diff] [blame] | 1393 | /* Dell OEM/Creative Labs Audigy 2 ZS */ |
| 1394 | /* See ALSA bug#1365 */ |
| 1395 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102, |
| 1396 | .driver = "Audigy2", .name = "Audigy 2 ZS [SB0353]", |
| 1397 | .id = "Audigy2", |
| 1398 | .emu10k2_chip = 1, |
| 1399 | .ca0102_chip = 1, |
| 1400 | .ca0151_chip = 1, |
| 1401 | .spk71 = 1, |
| 1402 | .spdif_bug = 1, |
| 1403 | .ac97_chip = 1} , |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, |
| 1405 | .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1406 | .id = "Audigy2", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1407 | .emu10k2_chip = 1, |
| 1408 | .ca0102_chip = 1, |
| 1409 | .ca0151_chip = 1, |
| 1410 | .spk71 = 1, |
| 1411 | .spdif_bug = 1, |
James Courtier-Dutton | 3271b7b | 2006-11-25 22:02:47 +0000 | [diff] [blame] | 1412 | .adc_1361t = 1, /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | .ac97_chip = 1} , |
Takashi Iwai | bdaed50 | 2005-04-07 15:48:42 +0200 | [diff] [blame] | 1414 | {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, |
| 1415 | .driver = "Audigy2", .name = "Audigy 2 [Unknown]", |
| 1416 | .id = "Audigy2", |
| 1417 | .emu10k2_chip = 1, |
| 1418 | .ca0102_chip = 1, |
| 1419 | .ca0151_chip = 1, |
| 1420 | .spdif_bug = 1, |
| 1421 | .ac97_chip = 1} , |
Peter Zubaj | 2668907 | 2005-04-01 11:15:07 +0200 | [diff] [blame] | 1422 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, |
| 1423 | .driver = "Audigy", .name = "Audigy 1 [SB0090]", |
| 1424 | .id = "Audigy", |
| 1425 | .emu10k2_chip = 1, |
| 1426 | .ca0102_chip = 1, |
| 1427 | .ac97_chip = 1} , |
James Courtier-Dutton | ae3a72d | 2005-07-06 22:36:18 +0200 | [diff] [blame] | 1428 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102, |
| 1429 | .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", |
| 1430 | .id = "Audigy", |
| 1431 | .emu10k2_chip = 1, |
| 1432 | .ca0102_chip = 1, |
| 1433 | .spdif_bug = 1, |
| 1434 | .ac97_chip = 1} , |
Arnaud Patard | a6c17ec | 2005-05-27 12:31:34 +0200 | [diff] [blame] | 1435 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, |
| 1436 | .driver = "Audigy", .name = "Audigy 1 [SB0090]", |
| 1437 | .id = "Audigy", |
| 1438 | .emu10k2_chip = 1, |
| 1439 | .ca0102_chip = 1, |
| 1440 | .ac97_chip = 1} , |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | {.vendor = 0x1102, .device = 0x0004, |
Takashi Iwai | bdaed50 | 2005-04-07 15:48:42 +0200 | [diff] [blame] | 1442 | .driver = "Audigy", .name = "Audigy 1 [Unknown]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1443 | .id = "Audigy", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | .emu10k2_chip = 1, |
| 1445 | .ca0102_chip = 1, |
Peter Zubaj | 2668907 | 2005-04-01 11:15:07 +0200 | [diff] [blame] | 1446 | .ac97_chip = 1} , |
James Courtier-Dutton | a6f6192 | 2005-07-03 12:32:40 +0200 | [diff] [blame] | 1447 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, |
| 1448 | .driver = "EMU10K1", .name = "SBLive! [SB0105]", |
James Courtier-Dutton | 2b6b22f | 2005-06-18 13:50:22 +0200 | [diff] [blame] | 1449 | .id = "Live", |
| 1450 | .emu10k1_chip = 1, |
| 1451 | .ac97_chip = 1, |
| 1452 | .sblive51 = 1} , |
| 1453 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, |
| 1454 | .driver = "EMU10K1", .name = "SBLive! Value [SB0103]", |
| 1455 | .id = "Live", |
| 1456 | .emu10k1_chip = 1, |
| 1457 | .ac97_chip = 1, |
| 1458 | .sblive51 = 1} , |
James Courtier-Dutton | a6f6192 | 2005-07-03 12:32:40 +0200 | [diff] [blame] | 1459 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, |
| 1460 | .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", |
| 1461 | .id = "Live", |
| 1462 | .emu10k1_chip = 1, |
| 1463 | .ac97_chip = 1, |
| 1464 | .sblive51 = 1} , |
James Courtier-Dutton | 0ba656d | 2005-12-26 15:30:03 +0100 | [diff] [blame] | 1465 | /* Tested by ALSA bug#1680 26th December 2005 */ |
| 1466 | /* note: It really has SB0220 written on the card. */ |
| 1467 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, |
| 1468 | .driver = "EMU10K1", .name = "SB Live 5.1 Dell OEM [SB0220]", |
| 1469 | .id = "Live", |
| 1470 | .emu10k1_chip = 1, |
| 1471 | .ac97_chip = 1, |
| 1472 | .sblive51 = 1} , |
Lee Revell | c6c0b84 | 2005-08-29 17:42:00 +0200 | [diff] [blame] | 1473 | /* Tested by Thomas Zehetbauer 27th Aug 2005 */ |
| 1474 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, |
| 1475 | .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", |
| 1476 | .id = "Live", |
| 1477 | .emu10k1_chip = 1, |
| 1478 | .ac97_chip = 1, |
| 1479 | .sblive51 = 1} , |
Gergely Tamas | a8ee729 | 2005-12-06 14:10:57 +0100 | [diff] [blame] | 1480 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102, |
| 1481 | .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", |
| 1482 | .id = "Live", |
| 1483 | .emu10k1_chip = 1, |
| 1484 | .ac97_chip = 1, |
| 1485 | .sblive51 = 1} , |
James Courtier-Dutton | a6f6192 | 2005-07-03 12:32:40 +0200 | [diff] [blame] | 1486 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, |
| 1487 | .driver = "EMU10K1", .name = "SB Live 5.1", |
| 1488 | .id = "Live", |
| 1489 | .emu10k1_chip = 1, |
| 1490 | .ac97_chip = 1, |
| 1491 | .sblive51 = 1} , |
James Courtier-Dutton | afe0f1f | 2005-09-10 10:24:10 +0200 | [diff] [blame] | 1492 | /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ |
James Courtier-Dutton | a6f6192 | 2005-07-03 12:32:40 +0200 | [diff] [blame] | 1493 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, |
Takashi Iwai | f12aa40 | 2005-09-30 16:56:59 +0200 | [diff] [blame] | 1494 | .driver = "EMU10K1", .name = "SBLive 5.1 [SB0060]", |
James Courtier-Dutton | a6f6192 | 2005-07-03 12:32:40 +0200 | [diff] [blame] | 1495 | .id = "Live", |
| 1496 | .emu10k1_chip = 1, |
Takashi Iwai | f12aa40 | 2005-09-30 16:56:59 +0200 | [diff] [blame] | 1497 | .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum |
| 1498 | * share the same IDs! |
| 1499 | */ |
James Courtier-Dutton | a6f6192 | 2005-07-03 12:32:40 +0200 | [diff] [blame] | 1500 | .sblive51 = 1} , |
| 1501 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, |
| 1502 | .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", |
| 1503 | .id = "Live", |
| 1504 | .emu10k1_chip = 1, |
| 1505 | .ac97_chip = 1, |
| 1506 | .sblive51 = 1} , |
| 1507 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, |
| 1508 | .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", |
| 1509 | .id = "Live", |
| 1510 | .emu10k1_chip = 1, |
| 1511 | .ac97_chip = 1} , |
| 1512 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, |
| 1513 | .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", |
| 1514 | .id = "Live", |
| 1515 | .emu10k1_chip = 1, |
| 1516 | .ac97_chip = 1, |
| 1517 | .sblive51 = 1} , |
| 1518 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, |
| 1519 | .driver = "EMU10K1", .name = "SBLive! Value [CT4831]", |
| 1520 | .id = "Live", |
| 1521 | .emu10k1_chip = 1, |
| 1522 | .ac97_chip = 1, |
| 1523 | .sblive51 = 1} , |
| 1524 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, |
| 1525 | .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", |
| 1526 | .id = "Live", |
| 1527 | .emu10k1_chip = 1, |
| 1528 | .ac97_chip = 1, |
| 1529 | .sblive51 = 1} , |
James Courtier-Dutton | 88dc0e5 | 2005-07-03 12:54:29 +0200 | [diff] [blame] | 1530 | /* Tested by James@superbug.co.uk 3rd July 2005 */ |
James Courtier-Dutton | a6f6192 | 2005-07-03 12:32:40 +0200 | [diff] [blame] | 1531 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, |
| 1532 | .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", |
| 1533 | .id = "Live", |
| 1534 | .emu10k1_chip = 1, |
| 1535 | .ac97_chip = 1, |
| 1536 | .sblive51 = 1} , |
| 1537 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, |
| 1538 | .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", |
| 1539 | .id = "Live", |
| 1540 | .emu10k1_chip = 1, |
| 1541 | .ac97_chip = 1, |
| 1542 | .sblive51 = 1} , |
| 1543 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, |
| 1544 | .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", |
| 1545 | .id = "Live", |
| 1546 | .emu10k1_chip = 1, |
| 1547 | .ac97_chip = 1, |
| 1548 | .sblive51 = 1} , |
| 1549 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, |
| 1550 | .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", |
| 1551 | .id = "Live", |
| 1552 | .emu10k1_chip = 1, |
| 1553 | .ac97_chip = 1, |
| 1554 | .sblive51 = 1} , |
| 1555 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, |
| 1556 | .driver = "EMU10K1", .name = "E-mu APS [4001]", |
| 1557 | .id = "APS", |
| 1558 | .emu10k1_chip = 1, |
| 1559 | .ecard = 1} , |
| 1560 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, |
| 1561 | .driver = "EMU10K1", .name = "SBLive! [CT4620]", |
| 1562 | .id = "Live", |
| 1563 | .emu10k1_chip = 1, |
| 1564 | .ac97_chip = 1, |
| 1565 | .sblive51 = 1} , |
| 1566 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, |
| 1567 | .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", |
James Courtier-Dutton | 2b6b22f | 2005-06-18 13:50:22 +0200 | [diff] [blame] | 1568 | .id = "Live", |
| 1569 | .emu10k1_chip = 1, |
| 1570 | .ac97_chip = 1, |
| 1571 | .sblive51 = 1} , |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1572 | {.vendor = 0x1102, .device = 0x0002, |
| 1573 | .driver = "EMU10K1", .name = "SB Live [Unknown]", |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1574 | .id = "Live", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | .emu10k1_chip = 1, |
Lee Revell | 2b637da | 2005-03-30 13:51:18 +0200 | [diff] [blame] | 1576 | .ac97_chip = 1, |
| 1577 | .sblive51 = 1} , |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | { } /* terminator */ |
| 1579 | }; |
| 1580 | |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1581 | int __devinit snd_emu10k1_create(struct snd_card *card, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1582 | struct pci_dev * pci, |
| 1583 | unsigned short extin_mask, |
| 1584 | unsigned short extout_mask, |
| 1585 | long max_cache_bytes, |
| 1586 | int enable_ir, |
James Courtier-Dutton | e66bc8b | 2005-07-06 22:21:51 +0200 | [diff] [blame] | 1587 | uint subsystem, |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1588 | struct snd_emu10k1 ** remu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1589 | { |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1590 | struct snd_emu10k1 *emu; |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1591 | int idx, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | int is_audigy; |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1593 | unsigned int silent_page; |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1594 | const struct snd_emu_chip_details *c; |
| 1595 | static struct snd_device_ops ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1596 | .dev_free = snd_emu10k1_dev_free, |
| 1597 | }; |
| 1598 | |
| 1599 | *remu = NULL; |
| 1600 | |
| 1601 | /* enable PCI device */ |
| 1602 | if ((err = pci_enable_device(pci)) < 0) |
| 1603 | return err; |
| 1604 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1605 | emu = kzalloc(sizeof(*emu), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1606 | if (emu == NULL) { |
| 1607 | pci_disable_device(pci); |
| 1608 | return -ENOMEM; |
| 1609 | } |
| 1610 | emu->card = card; |
| 1611 | spin_lock_init(&emu->reg_lock); |
| 1612 | spin_lock_init(&emu->emu_lock); |
| 1613 | spin_lock_init(&emu->voice_lock); |
| 1614 | spin_lock_init(&emu->synth_lock); |
| 1615 | spin_lock_init(&emu->memblk_lock); |
Ingo Molnar | 62932df | 2006-01-16 16:34:20 +0100 | [diff] [blame] | 1616 | mutex_init(&emu->fx8010.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | INIT_LIST_HEAD(&emu->mapped_link_head); |
| 1618 | INIT_LIST_HEAD(&emu->mapped_order_link_head); |
| 1619 | emu->pci = pci; |
| 1620 | emu->irq = -1; |
| 1621 | emu->synth = NULL; |
| 1622 | emu->get_synth_voice = NULL; |
| 1623 | /* read revision & serial */ |
Auke Kok | 44c1013 | 2007-06-08 15:46:36 -0700 | [diff] [blame] | 1624 | emu->revision = pci->revision; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); |
| 1626 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model); |
| 1628 | |
| 1629 | for (c = emu_chip_details; c->vendor; c++) { |
| 1630 | if (c->vendor == pci->vendor && c->device == pci->device) { |
James Courtier-Dutton | e66bc8b | 2005-07-06 22:21:51 +0200 | [diff] [blame] | 1631 | if (subsystem) { |
| 1632 | if (c->subsystem && (c->subsystem == subsystem) ) { |
| 1633 | break; |
| 1634 | } else continue; |
| 1635 | } else { |
| 1636 | if (c->subsystem && (c->subsystem != emu->serial) ) |
| 1637 | continue; |
| 1638 | if (c->revision && c->revision != emu->revision) |
| 1639 | continue; |
| 1640 | } |
Takashi Iwai | bdaed50 | 2005-04-07 15:48:42 +0200 | [diff] [blame] | 1641 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | } |
| 1643 | } |
| 1644 | if (c->vendor == 0) { |
| 1645 | snd_printk(KERN_ERR "emu10k1: Card not recognised\n"); |
| 1646 | kfree(emu); |
| 1647 | pci_disable_device(pci); |
| 1648 | return -ENOENT; |
| 1649 | } |
| 1650 | emu->card_capabilities = c; |
James Courtier-Dutton | e66bc8b | 2005-07-06 22:21:51 +0200 | [diff] [blame] | 1651 | if (c->subsystem && !subsystem) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1652 | snd_printdd("Sound card name=%s\n", c->name); |
James Courtier-Dutton | e66bc8b | 2005-07-06 22:21:51 +0200 | [diff] [blame] | 1653 | else if (subsystem) |
| 1654 | snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x. Forced to subsytem=0x%x\n", |
| 1655 | c->name, pci->vendor, pci->device, emu->serial, c->subsystem); |
| 1656 | else |
| 1657 | snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x.\n", |
| 1658 | c->name, pci->vendor, pci->device, emu->serial); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1659 | |
Takashi Iwai | 85a655d | 2005-03-30 14:40:25 +0200 | [diff] [blame] | 1660 | if (!*card->id && c->id) { |
| 1661 | int i, n = 0; |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1662 | strlcpy(card->id, c->id, sizeof(card->id)); |
Takashi Iwai | 85a655d | 2005-03-30 14:40:25 +0200 | [diff] [blame] | 1663 | for (;;) { |
| 1664 | for (i = 0; i < snd_ecards_limit; i++) { |
| 1665 | if (snd_cards[i] && !strcmp(snd_cards[i]->id, card->id)) |
| 1666 | break; |
| 1667 | } |
| 1668 | if (i >= snd_ecards_limit) |
| 1669 | break; |
| 1670 | n++; |
| 1671 | if (n >= SNDRV_CARDS) |
| 1672 | break; |
| 1673 | snprintf(card->id, sizeof(card->id), "%s_%d", c->id, n); |
| 1674 | } |
| 1675 | } |
Takashi Iwai | aec72e0 | 2005-03-30 14:22:25 +0200 | [diff] [blame] | 1676 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1677 | is_audigy = emu->audigy = c->emu10k2_chip; |
| 1678 | |
| 1679 | /* set the DMA transfer mask */ |
| 1680 | emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK; |
| 1681 | if (pci_set_dma_mask(pci, emu->dma_mask) < 0 || |
| 1682 | pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) { |
| 1683 | snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask); |
| 1684 | kfree(emu); |
| 1685 | pci_disable_device(pci); |
| 1686 | return -ENXIO; |
| 1687 | } |
| 1688 | if (is_audigy) |
| 1689 | emu->gpr_base = A_FXGPREGBASE; |
| 1690 | else |
| 1691 | emu->gpr_base = FXGPREGBASE; |
| 1692 | |
| 1693 | if ((err = pci_request_regions(pci, "EMU10K1")) < 0) { |
| 1694 | kfree(emu); |
| 1695 | pci_disable_device(pci); |
| 1696 | return err; |
| 1697 | } |
| 1698 | emu->port = pci_resource_start(pci, 0); |
| 1699 | |
Takashi Iwai | 437a5a4 | 2006-11-21 12:14:23 +0100 | [diff] [blame] | 1700 | if (request_irq(pci->irq, snd_emu10k1_interrupt, IRQF_SHARED, |
| 1701 | "EMU10K1", emu)) { |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1702 | err = -EBUSY; |
| 1703 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | } |
| 1705 | emu->irq = pci->irq; |
| 1706 | |
| 1707 | emu->max_cache_pages = max_cache_bytes >> PAGE_SHIFT; |
| 1708 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), |
| 1709 | 32 * 1024, &emu->ptb_pages) < 0) { |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1710 | err = -ENOMEM; |
| 1711 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1712 | } |
| 1713 | |
| 1714 | emu->page_ptr_table = (void **)vmalloc(emu->max_cache_pages * sizeof(void*)); |
| 1715 | emu->page_addr_table = (unsigned long*)vmalloc(emu->max_cache_pages * sizeof(unsigned long)); |
| 1716 | if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1717 | err = -ENOMEM; |
| 1718 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1719 | } |
| 1720 | |
| 1721 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), |
| 1722 | EMUPAGESIZE, &emu->silent_page) < 0) { |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1723 | err = -ENOMEM; |
| 1724 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1725 | } |
| 1726 | emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE); |
| 1727 | if (emu->memhdr == NULL) { |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1728 | err = -ENOMEM; |
| 1729 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1730 | } |
Takashi Iwai | eb4698f | 2005-11-17 14:50:13 +0100 | [diff] [blame] | 1731 | emu->memhdr->block_extra_size = sizeof(struct snd_emu10k1_memblk) - |
| 1732 | sizeof(struct snd_util_memblk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | |
| 1734 | pci_set_master(pci); |
| 1735 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | emu->fx8010.fxbus_mask = 0x303f; |
| 1737 | if (extin_mask == 0) |
| 1738 | extin_mask = 0x3fcf; |
| 1739 | if (extout_mask == 0) |
| 1740 | extout_mask = 0x7fff; |
| 1741 | emu->fx8010.extin_mask = extin_mask; |
| 1742 | emu->fx8010.extout_mask = extout_mask; |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1743 | emu->enable_ir = enable_ir; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1744 | |
Lee Revell | 2b637da | 2005-03-30 13:51:18 +0200 | [diff] [blame] | 1745 | if (emu->card_capabilities->ecard) { |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1746 | if ((err = snd_emu10k1_ecard_init(emu)) < 0) |
| 1747 | goto error; |
James Courtier-Dutton | d83c671 | 2005-10-31 10:27:41 +0000 | [diff] [blame] | 1748 | } else if (emu->card_capabilities->ca_cardbus_chip) { |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1749 | if ((err = snd_emu10k1_cardbus_init(emu)) < 0) |
| 1750 | goto error; |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1751 | } else if (emu->card_capabilities->emu1010) { |
| 1752 | if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { |
James Courtier-Dutton | 19b99fb | 2005-12-04 18:03:03 +0100 | [diff] [blame] | 1753 | snd_emu10k1_free(emu); |
| 1754 | return err; |
| 1755 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | } else { |
| 1757 | /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version |
| 1758 | does not support this, it shouldn't do any harm */ |
| 1759 | snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); |
| 1760 | } |
| 1761 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1762 | /* initialize TRAM setup */ |
| 1763 | emu->fx8010.itram_size = (16 * 1024)/2; |
| 1764 | emu->fx8010.etram_pages.area = NULL; |
| 1765 | emu->fx8010.etram_pages.bytes = 0; |
| 1766 | |
| 1767 | /* |
| 1768 | * Init to 0x02109204 : |
| 1769 | * Clock accuracy = 0 (1000ppm) |
| 1770 | * Sample Rate = 2 (48kHz) |
| 1771 | * Audio Channel = 1 (Left of 2) |
| 1772 | * Source Number = 0 (Unspecified) |
| 1773 | * Generation Status = 1 (Original for Cat Code 12) |
| 1774 | * Cat Code = 12 (Digital Signal Mixer) |
| 1775 | * Mode = 0 (Mode 0) |
| 1776 | * Emphasis = 0 (None) |
| 1777 | * CP = 1 (Copyright unasserted) |
| 1778 | * AN = 0 (Audio data) |
| 1779 | * P = 0 (Consumer) |
| 1780 | */ |
| 1781 | emu->spdif_bits[0] = emu->spdif_bits[1] = |
| 1782 | emu->spdif_bits[2] = SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | |
| 1783 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | |
| 1784 | SPCS_GENERATIONSTATUS | 0x00001200 | |
| 1785 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT; |
| 1786 | |
| 1787 | emu->reserved_page = (struct snd_emu10k1_memblk *) |
| 1788 | snd_emu10k1_synth_alloc(emu, 4096); |
| 1789 | if (emu->reserved_page) |
| 1790 | emu->reserved_page->map_locked = 1; |
| 1791 | |
| 1792 | /* Clear silent pages and set up pointers */ |
| 1793 | memset(emu->silent_page.area, 0, PAGE_SIZE); |
| 1794 | silent_page = emu->silent_page.addr << 1; |
| 1795 | for (idx = 0; idx < MAXPAGES; idx++) |
| 1796 | ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx); |
| 1797 | |
| 1798 | /* set up voice indices */ |
| 1799 | for (idx = 0; idx < NUM_G; idx++) { |
| 1800 | emu->voices[idx].emu = emu; |
| 1801 | emu->voices[idx].number = idx; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1802 | } |
| 1803 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1804 | if ((err = snd_emu10k1_init(emu, enable_ir, 0)) < 0) |
| 1805 | goto error; |
| 1806 | #ifdef CONFIG_PM |
| 1807 | if ((err = alloc_pm_buffer(emu)) < 0) |
| 1808 | goto error; |
| 1809 | #endif |
| 1810 | |
| 1811 | /* Initialize the effect engine */ |
| 1812 | if ((err = snd_emu10k1_init_efx(emu)) < 0) |
| 1813 | goto error; |
| 1814 | snd_emu10k1_audio_enable(emu); |
| 1815 | |
| 1816 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) |
| 1817 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1818 | |
Takashi Iwai | adf1b3d | 2005-12-01 10:49:58 +0100 | [diff] [blame] | 1819 | #ifdef CONFIG_PROC_FS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1820 | snd_emu10k1_proc_init(emu); |
Takashi Iwai | adf1b3d | 2005-12-01 10:49:58 +0100 | [diff] [blame] | 1821 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | |
| 1823 | snd_card_set_dev(card, &pci->dev); |
| 1824 | *remu = emu; |
| 1825 | return 0; |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1826 | |
| 1827 | error: |
| 1828 | snd_emu10k1_free(emu); |
| 1829 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1830 | } |
| 1831 | |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1832 | #ifdef CONFIG_PM |
| 1833 | static unsigned char saved_regs[] = { |
| 1834 | CPF, PTRX, CVCF, VTFT, Z1, Z2, PSST, DSL, CCCA, CCR, CLP, |
| 1835 | FXRT, MAPA, MAPB, ENVVOL, ATKHLDV, DCYSUSV, LFOVAL1, ENVVAL, |
| 1836 | ATKHLDM, DCYSUSM, LFOVAL2, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2, |
| 1837 | TEMPENV, ADCCR, FXWC, MICBA, ADCBA, FXBA, |
| 1838 | MICBS, ADCBS, FXBS, CDCS, GPSCS, SPCS0, SPCS1, SPCS2, |
| 1839 | SPBYPASS, AC97SLOT, CDSRCS, GPSRCS, ZVSRCS, MICIDX, ADCIDX, FXIDX, |
| 1840 | 0xff /* end */ |
| 1841 | }; |
| 1842 | static unsigned char saved_regs_audigy[] = { |
| 1843 | A_ADCIDX, A_MICIDX, A_FXWC1, A_FXWC2, A_SAMPLE_RATE, |
| 1844 | A_FXRT2, A_SENDAMOUNTS, A_FXRT1, |
| 1845 | 0xff /* end */ |
| 1846 | }; |
| 1847 | |
| 1848 | static int __devinit alloc_pm_buffer(struct snd_emu10k1 *emu) |
| 1849 | { |
| 1850 | int size; |
| 1851 | |
| 1852 | size = ARRAY_SIZE(saved_regs); |
| 1853 | if (emu->audigy) |
| 1854 | size += ARRAY_SIZE(saved_regs_audigy); |
| 1855 | emu->saved_ptr = vmalloc(4 * NUM_G * size); |
| 1856 | if (! emu->saved_ptr) |
| 1857 | return -ENOMEM; |
| 1858 | if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) |
| 1859 | return -ENOMEM; |
| 1860 | if (emu->card_capabilities->ca0151_chip && |
| 1861 | snd_p16v_alloc_pm_buffer(emu) < 0) |
| 1862 | return -ENOMEM; |
| 1863 | return 0; |
| 1864 | } |
| 1865 | |
| 1866 | static void free_pm_buffer(struct snd_emu10k1 *emu) |
| 1867 | { |
| 1868 | vfree(emu->saved_ptr); |
| 1869 | snd_emu10k1_efx_free_pm_buffer(emu); |
| 1870 | if (emu->card_capabilities->ca0151_chip) |
| 1871 | snd_p16v_free_pm_buffer(emu); |
| 1872 | } |
| 1873 | |
| 1874 | void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu) |
| 1875 | { |
| 1876 | int i; |
| 1877 | unsigned char *reg; |
| 1878 | unsigned int *val; |
| 1879 | |
| 1880 | val = emu->saved_ptr; |
| 1881 | for (reg = saved_regs; *reg != 0xff; reg++) |
| 1882 | for (i = 0; i < NUM_G; i++, val++) |
| 1883 | *val = snd_emu10k1_ptr_read(emu, *reg, i); |
| 1884 | if (emu->audigy) { |
| 1885 | for (reg = saved_regs_audigy; *reg != 0xff; reg++) |
| 1886 | for (i = 0; i < NUM_G; i++, val++) |
| 1887 | *val = snd_emu10k1_ptr_read(emu, *reg, i); |
| 1888 | } |
| 1889 | if (emu->audigy) |
| 1890 | emu->saved_a_iocfg = inl(emu->port + A_IOCFG); |
| 1891 | emu->saved_hcfg = inl(emu->port + HCFG); |
| 1892 | } |
| 1893 | |
| 1894 | void snd_emu10k1_resume_init(struct snd_emu10k1 *emu) |
| 1895 | { |
| 1896 | if (emu->card_capabilities->ecard) |
| 1897 | snd_emu10k1_ecard_init(emu); |
Takashi Iwai | f40b689 | 2006-07-05 16:51:05 +0200 | [diff] [blame] | 1898 | else if (emu->card_capabilities->ca_cardbus_chip) |
| 1899 | snd_emu10k1_cardbus_init(emu); |
James Courtier-Dutton | 9f4bd5d | 2006-10-01 10:48:04 +0100 | [diff] [blame] | 1900 | else if (emu->card_capabilities->emu1010) |
| 1901 | snd_emu10k1_emu1010_init(emu); |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1902 | else |
| 1903 | snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); |
| 1904 | snd_emu10k1_init(emu, emu->enable_ir, 1); |
| 1905 | } |
| 1906 | |
| 1907 | void snd_emu10k1_resume_regs(struct snd_emu10k1 *emu) |
| 1908 | { |
| 1909 | int i; |
| 1910 | unsigned char *reg; |
| 1911 | unsigned int *val; |
| 1912 | |
| 1913 | snd_emu10k1_audio_enable(emu); |
| 1914 | |
| 1915 | /* resore for spdif */ |
| 1916 | if (emu->audigy) |
Arnaud Patard | 4130d59 | 2006-10-04 18:21:05 +0200 | [diff] [blame] | 1917 | outl(emu->saved_a_iocfg, emu->port + A_IOCFG); |
| 1918 | outl(emu->saved_hcfg, emu->port + HCFG); |
Takashi Iwai | 09668b4 | 2005-11-17 16:14:10 +0100 | [diff] [blame] | 1919 | |
| 1920 | val = emu->saved_ptr; |
| 1921 | for (reg = saved_regs; *reg != 0xff; reg++) |
| 1922 | for (i = 0; i < NUM_G; i++, val++) |
| 1923 | snd_emu10k1_ptr_write(emu, *reg, i, *val); |
| 1924 | if (emu->audigy) { |
| 1925 | for (reg = saved_regs_audigy; *reg != 0xff; reg++) |
| 1926 | for (i = 0; i < NUM_G; i++, val++) |
| 1927 | snd_emu10k1_ptr_write(emu, *reg, i, *val); |
| 1928 | } |
| 1929 | } |
| 1930 | #endif |