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