34 #include <linux/sched.h>
38 #include <linux/module.h>
40 #include <linux/pci.h>
41 #include <linux/slab.h>
54 #define HANA_FILENAME "emu/hana.fw"
55 #define DOCK_FILENAME "emu/audio_dock.fw"
56 #define EMU1010B_FILENAME "emu/emu1010b.fw"
57 #define MICRO_DOCK_FILENAME "emu/micro_dock.fw"
58 #define EMU0404_FILENAME "emu/emu0404.fw"
59 #define EMU1010_NOTEBOOK_FILENAME "emu/emu1010_notebook.fw"
118 static unsigned int spi_dac_init[] = {
142 static unsigned int i2c_adc_init[][2] = {
158 static int snd_emu10k1_init(
struct snd_emu10k1 *
emu,
int enable_ir,
int resume)
160 unsigned int silent_page;
166 HCFG_MUTEBUTTONENABLE, emu->port +
HCFG);
192 for (ch = 0; ch < NUM_G; ch++)
199 if (emu->card_capabilities->ca0151_chip) {
214 outl(0x0201, emu->port + HCFG2);
218 if (emu->card_capabilities->ca0108_chip) {
228 outl(0x600000, emu->port + 0x20);
229 outl(0x14, emu->port + 0x24);
232 outl(0x7b0000, emu->port + 0x20);
233 outl(0xFF000000, emu->port + 0x24);
239 outl(0x7a0000, emu->port + 0x20);
240 outl(0xFF000000, emu->port + 0x24);
241 tmp =
inl(emu->port + A_IOCFG) & ~0x8;
242 outl(tmp, emu->port + A_IOCFG);
244 if (emu->card_capabilities->spi_dac) {
248 for (n = 0; n <
size; n++)
262 outl(0x76, emu->port + A_IOCFG);
264 if (emu->card_capabilities->i2c_adc) {
268 tmp =
inl(emu->port + A_IOCFG);
269 outl(tmp | 0x4, emu->port + A_IOCFG);
270 tmp =
inl(emu->port + A_IOCFG);
272 for (n = 0; n <
size; n++)
274 for (n = 0; n < 4; n++) {
275 emu->i2c_capture_volume[
n][0] = 0xcf;
276 emu->i2c_capture_volume[
n][1] = 0xcf;
285 silent_page = (emu->silent_page.addr << 1) | MAP_PTI_MASK;
286 for (ch = 0; ch < NUM_G; ch++) {
291 if (emu->card_capabilities->emu_model) {
292 outl(HCFG_AUTOMUTE_ASYNC |
302 }
else if (emu->audigy) {
303 if (emu->revision == 4)
305 HCFG_AC3ENABLE_CDSPDIF |
306 HCFG_AC3ENABLE_GPSPDIF |
307 HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port +
HCFG);
309 outl(HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port +
HCFG);
312 }
else if (emu->model == 0x20 ||
313 emu->model == 0xc400 ||
314 (emu->model == 0x21 && emu->revision < 6))
315 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE, emu->port +
HCFG);
318 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port +
HCFG);
321 if (emu->card_capabilities->emu_model) {
323 }
else if (emu->card_capabilities->i2c_adc) {
325 }
else if (emu->audigy) {
326 unsigned int reg =
inl(emu->port + A_IOCFG);
327 outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG);
329 outl(reg | A_IOCFG_GPOUT1 | A_IOCFG_GPOUT2, emu->port + A_IOCFG);
331 outl(reg, emu->port + A_IOCFG);
334 outl(reg | HCFG_GPOUT2, emu->port +
HCFG);
336 outl(reg | HCFG_GPOUT1 | HCFG_GPOUT2, emu->port +
HCFG);
342 if (emu->card_capabilities->emu_model) {
344 }
else if (emu->card_capabilities->i2c_adc) {
346 }
else if (emu->audigy) {
347 unsigned int reg =
inl(emu->port + A_IOCFG);
348 outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG);
354 static void snd_emu10k1_audio_enable(
struct snd_emu10k1 *emu)
362 if (emu->card_capabilities->emu_model) {
364 }
else if (emu->card_capabilities->i2c_adc) {
366 }
else if (emu->audigy) {
367 outl(
inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG);
369 if (emu->card_capabilities->ca0151_chip) {
373 outl(
inl(emu->port + A_IOCFG) | 0x0040, emu->port + A_IOCFG);
374 }
else if (emu->card_capabilities->ca0108_chip) {
376 outl(
inl(emu->port + A_IOCFG) | 0x0060, emu->port + A_IOCFG);
379 outl(
inl(emu->port + A_IOCFG) | 0x0080, emu->port + A_IOCFG);
390 if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) {
393 if (tmp != (
inl(emu->port +
HCFG) & ~0x800)) {
413 for (ch = 0; ch < NUM_G; ch++)
415 for (ch = 0; ch < NUM_G; ch++) {
455 #define HOOKN_BIT (1L << 12)
456 #define HANDN_BIT (1L << 11)
457 #define PULSEN_BIT (1L << 10)
459 #define EC_GDI1 (1 << 13)
460 #define EC_GDI0 (1 << 14)
462 #define EC_NUM_CONTROL_BITS 20
464 #define EC_AC3_DATA_SELN 0x0001L
465 #define EC_EE_DATA_SEL 0x0002L
466 #define EC_EE_CNTRL_SELN 0x0004L
467 #define EC_EECLK 0x0008L
468 #define EC_EECS 0x0010L
469 #define EC_EESDO 0x0020L
470 #define EC_TRIM_CSN 0x0040L
471 #define EC_TRIM_SCLK 0x0080L
472 #define EC_TRIM_SDATA 0x0100L
473 #define EC_TRIM_MUTEN 0x0200L
474 #define EC_ADCCAL 0x0400L
475 #define EC_ADCRSTN 0x0800L
476 #define EC_DACCAL 0x1000L
477 #define EC_DACMUTEN 0x2000L
478 #define EC_LEDN 0x4000L
480 #define EC_SPDIF0_SEL_SHIFT 15
481 #define EC_SPDIF1_SEL_SHIFT 17
482 #define EC_SPDIF0_SEL_MASK (0x3L << EC_SPDIF0_SEL_SHIFT)
483 #define EC_SPDIF1_SEL_MASK (0x7L << EC_SPDIF1_SEL_SHIFT)
484 #define EC_SPDIF0_SELECT(_x) (((_x) << EC_SPDIF0_SEL_SHIFT) & EC_SPDIF0_SEL_MASK)
485 #define EC_SPDIF1_SELECT(_x) (((_x) << EC_SPDIF1_SEL_SHIFT) & EC_SPDIF1_SEL_MASK)
486 #define EC_CURRENT_PROM_VERSION 0x01
490 #define EC_EEPROM_SIZE 0x40
493 #define EC_PROM_VERSION_ADDR 0x20
494 #define EC_BOARDREV0_ADDR 0x21
495 #define EC_BOARDREV1_ADDR 0x22
497 #define EC_LAST_PROMFILE_ADDR 0x2f
499 #define EC_SERIALNUM_ADDR 0x30
504 #define EC_CHECKSUM_ADDR 0x3f
511 #define EC_RAW_RUN_MODE (EC_DACMUTEN | EC_ADCRSTN | EC_TRIM_MUTEN | \
515 #define EC_DEFAULT_ADC_GAIN 0xC4C4
516 #define EC_DEFAULT_SPDIF0_SEL 0x0
517 #define EC_DEFAULT_SPDIF1_SEL 0x4
527 static void snd_emu10k1_ecard_write(
struct snd_emu10k1 *emu,
unsigned int value)
529 unsigned short count;
531 unsigned long hc_port;
532 unsigned int hc_value;
534 hc_port = emu->port +
HCFG;
536 outl(hc_value, hc_port);
544 outl(hc_value | data, hc_port);
548 outl(hc_value | data, hc_port);
553 outl(hc_value, hc_port);
565 static void snd_emu10k1_ecard_setadcgain(
struct snd_emu10k1 *emu,
571 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl & ~
EC_TRIM_CSN);
574 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl & ~
EC_TRIM_CSN);
576 for (bit = (1 << 15);
bit; bit >>= 1) {
585 snd_emu10k1_ecard_write(emu, value);
587 snd_emu10k1_ecard_write(emu, value);
590 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl);
593 static int snd_emu10k1_ecard_init(
struct snd_emu10k1 *emu)
595 unsigned int hc_value;
604 hc_value =
inl(emu->port +
HCFG);
625 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl);
633 static int snd_emu10k1_cardbus_init(
struct snd_emu10k1 *emu)
635 unsigned long special_port;
641 special_port = emu->port + 0x38;
642 value =
inl(special_port);
643 outl(0x00d00000, special_port);
644 value =
inl(special_port);
645 outl(0x00d00001, special_port);
646 value =
inl(special_port);
647 outl(0x00d0005f, special_port);
648 value =
inl(special_port);
649 outl(0x00d0007f, special_port);
650 value =
inl(special_port);
651 outl(0x0090007f, special_port);
652 value =
inl(special_port);
660 static int snd_emu1010_load_firmware(
struct snd_emu10k1 *emu,
const char *
filename)
666 unsigned int write_post;
684 outl(0x00, emu->port + A_IOCFG);
685 write_post =
inl(emu->port + A_IOCFG);
687 outl(0x80, emu->port + A_IOCFG);
688 write_post =
inl(emu->port + A_IOCFG);
690 for (n = 0; n < fw_entry->
size; n++) {
691 value = fw_entry->
data[
n];
692 for (i = 0; i < 8; i++) {
697 outl(reg, emu->port + A_IOCFG);
698 write_post =
inl(emu->port + A_IOCFG);
699 outl(reg | 0x40, emu->port + A_IOCFG);
700 write_post =
inl(emu->port + A_IOCFG);
704 outl(0x10, emu->port + A_IOCFG);
705 write_post =
inl(emu->port + A_IOCFG);
706 spin_unlock_irqrestore(&emu->emu_lock, flags);
712 static int emu1010_firmware_thread(
void *
data)
714 struct snd_emu10k1 *emu =
data;
725 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) {
730 if (emu->card_capabilities->emu_model ==
735 }
else if (emu->card_capabilities->emu_model ==
736 EMU_MODEL_EMU1010B) {
740 }
else if (emu->card_capabilities->emu_model ==
753 if ((reg & 0x1f) != 0x15) {
755 snd_printk(
KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", reg);
805 static int snd_emu10k1_emu1010_init(
struct snd_emu10k1 *emu)
810 const char *filename =
NULL;
838 if ((reg & 0x3f) == 0x15) {
846 if ((reg & 0x3f) == 0x15) {
852 switch (emu->card_capabilities->emu_model) {
853 case EMU_MODEL_EMU1010:
856 case EMU_MODEL_EMU1010B:
859 case EMU_MODEL_EMU1616:
862 case EMU_MODEL_EMU0404:
871 err = snd_emu1010_load_firmware(emu, filename);
874 KERN_INFO "emu1010: Loading Firmware file %s failed\n",
881 if ((reg & 0x3f) != 0x15) {
903 emu->emu1010.optical_in = 1;
904 emu->emu1010.optical_out = 1;
906 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) |
907 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0);
912 emu->emu1010.adc_pads = 0x00;
920 emu->emu1010.dac_pads = 0x0f;
948 EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1);
950 EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1);
952 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT2);
954 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT2);
959 EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1);
961 EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1);
963 EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2);
965 EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_RIGHT2);
967 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT3);
969 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT3);
971 EMU_DST_ALICE2_EMU32_6, EMU_SRC_HAMOA_ADC_LEFT4);
973 EMU_DST_ALICE2_EMU32_7, EMU_SRC_HAMOA_ADC_RIGHT4);
978 EMU_DST_ALICE2_EMU32_0, EMU_SRC_DOCK_MIC_A1);
980 EMU_DST_ALICE2_EMU32_1, EMU_SRC_DOCK_MIC_B1);
982 EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2);
984 EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_LEFT2);
986 EMU_DST_ALICE2_EMU32_4, EMU_SRC_DOCK_ADC1_LEFT1);
988 EMU_DST_ALICE2_EMU32_5, EMU_SRC_DOCK_ADC1_RIGHT1);
990 EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1);
992 EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1);
999 EMU_DST_ALICE2_EMU32_8, EMU_SRC_DOCK_MIC_A1);
1001 EMU_DST_ALICE2_EMU32_9, EMU_SRC_DOCK_MIC_B1);
1003 EMU_DST_ALICE2_EMU32_A, EMU_SRC_HAMOA_ADC_LEFT2);
1005 EMU_DST_ALICE2_EMU32_B, EMU_SRC_HAMOA_ADC_LEFT2);
1007 EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_ADC1_LEFT1);
1009 EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_ADC1_RIGHT1);
1011 EMU_DST_ALICE2_EMU32_E, EMU_SRC_DOCK_ADC2_LEFT1);
1013 EMU_DST_ALICE2_EMU32_F, EMU_SRC_DOCK_ADC2_RIGHT1);
1018 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HANA_ADAT);
1020 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HANA_ADAT + 1);
1022 EMU_DST_ALICE2_EMU32_6, EMU_SRC_HANA_ADAT + 2);
1024 EMU_DST_ALICE2_EMU32_7, EMU_SRC_HANA_ADAT + 3);
1026 EMU_DST_ALICE2_EMU32_8, EMU_SRC_HANA_ADAT + 4);
1028 EMU_DST_ALICE2_EMU32_9, EMU_SRC_HANA_ADAT + 5);
1030 EMU_DST_ALICE2_EMU32_A, EMU_SRC_HANA_ADAT + 6);
1032 EMU_DST_ALICE2_EMU32_B, EMU_SRC_HANA_ADAT + 7);
1034 EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_MIC_A1);
1036 EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_MIC_B1);
1038 EMU_DST_ALICE2_EMU32_E, EMU_SRC_HAMOA_ADC_LEFT2);
1040 EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2);
1042 for (i = 0; i < 0x20; i++) {
1046 for (i = 0; i < 4; i++) {
1050 for (i = 0; i < 7; i++) {
1054 for (i = 0; i < 7; i++) {
1059 EMU_DST_ALICE_I2S0_LEFT, EMU_SRC_DOCK_ADC1_LEFT1);
1061 EMU_DST_ALICE_I2S0_RIGHT, EMU_SRC_DOCK_ADC1_RIGHT1);
1063 EMU_DST_ALICE_I2S1_LEFT, EMU_SRC_DOCK_ADC2_LEFT1);
1065 EMU_DST_ALICE_I2S1_RIGHT, EMU_SRC_DOCK_ADC2_RIGHT1);
1067 EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1);
1069 EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1);
1078 outl(0x0000a000, emu->port +
HCFG);
1083 outl(0x0000a001, emu->port +
HCFG);
1096 if (!emu->emu1010.firmware_thread) {
1097 emu->emu1010.firmware_thread =
1099 "emu1010_firmware");
1105 EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32B + 2);
1107 EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32B + 3);
1109 EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 2);
1111 EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 3);
1114 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) {
1118 EMU_DST_DOCK_DAC1_LEFT1, EMU_SRC_ALICE_EMU32A + 0);
1119 emu->emu1010.output_source[0] = 17;
1121 EMU_DST_DOCK_DAC1_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
1122 emu->emu1010.output_source[1] = 18;
1124 EMU_DST_DOCK_DAC2_LEFT1, EMU_SRC_ALICE_EMU32A + 2);
1125 emu->emu1010.output_source[2] = 19;
1127 EMU_DST_DOCK_DAC2_RIGHT1, EMU_SRC_ALICE_EMU32A + 3);
1128 emu->emu1010.output_source[3] = 20;
1130 EMU_DST_DOCK_DAC3_LEFT1, EMU_SRC_ALICE_EMU32A + 4);
1131 emu->emu1010.output_source[4] = 21;
1133 EMU_DST_DOCK_DAC3_RIGHT1, EMU_SRC_ALICE_EMU32A + 5);
1134 emu->emu1010.output_source[5] = 22;
1137 EMU_DST_MANA_DAC_LEFT, EMU_SRC_ALICE_EMU32A + 0);
1138 emu->emu1010.output_source[16] = 17;
1140 EMU_DST_MANA_DAC_RIGHT, EMU_SRC_ALICE_EMU32A + 1);
1141 emu->emu1010.output_source[17] = 18;
1145 EMU_DST_DOCK_DAC1_LEFT1, EMU_SRC_ALICE_EMU32A + 0);
1146 emu->emu1010.output_source[0] = 21;
1148 EMU_DST_DOCK_DAC1_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
1149 emu->emu1010.output_source[1] = 22;
1151 EMU_DST_DOCK_DAC2_LEFT1, EMU_SRC_ALICE_EMU32A + 2);
1152 emu->emu1010.output_source[2] = 23;
1154 EMU_DST_DOCK_DAC2_RIGHT1, EMU_SRC_ALICE_EMU32A + 3);
1155 emu->emu1010.output_source[3] = 24;
1157 EMU_DST_DOCK_DAC3_LEFT1, EMU_SRC_ALICE_EMU32A + 4);
1158 emu->emu1010.output_source[4] = 25;
1160 EMU_DST_DOCK_DAC3_RIGHT1, EMU_SRC_ALICE_EMU32A + 5);
1161 emu->emu1010.output_source[5] = 26;
1163 EMU_DST_DOCK_DAC4_LEFT1, EMU_SRC_ALICE_EMU32A + 6);
1164 emu->emu1010.output_source[6] = 27;
1166 EMU_DST_DOCK_DAC4_RIGHT1, EMU_SRC_ALICE_EMU32A + 7);
1167 emu->emu1010.output_source[7] = 28;
1170 EMU_DST_DOCK_PHONES_LEFT1, EMU_SRC_ALICE_EMU32A + 0);
1171 emu->emu1010.output_source[8] = 21;
1173 EMU_DST_DOCK_PHONES_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
1174 emu->emu1010.output_source[9] = 22;
1177 EMU_DST_DOCK_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0);
1178 emu->emu1010.output_source[10] = 21;
1180 EMU_DST_DOCK_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
1181 emu->emu1010.output_source[11] = 22;
1184 EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0);
1185 emu->emu1010.output_source[12] = 21;
1187 EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
1188 emu->emu1010.output_source[13] = 22;
1191 EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32A + 0);
1192 emu->emu1010.output_source[14] = 21;
1194 EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
1195 emu->emu1010.output_source[15] = 22;
1198 EMU_DST_HANA_ADAT, EMU_SRC_ALICE_EMU32A + 0);
1199 emu->emu1010.output_source[16] = 21;
1201 EMU_DST_HANA_ADAT + 1, EMU_SRC_ALICE_EMU32A + 1);
1202 emu->emu1010.output_source[17] = 22;
1204 EMU_DST_HANA_ADAT + 2, EMU_SRC_ALICE_EMU32A + 2);
1205 emu->emu1010.output_source[18] = 23;
1207 EMU_DST_HANA_ADAT + 3, EMU_SRC_ALICE_EMU32A + 3);
1208 emu->emu1010.output_source[19] = 24;
1210 EMU_DST_HANA_ADAT + 4, EMU_SRC_ALICE_EMU32A + 4);
1211 emu->emu1010.output_source[20] = 25;
1213 EMU_DST_HANA_ADAT + 5, EMU_SRC_ALICE_EMU32A + 5);
1214 emu->emu1010.output_source[21] = 26;
1216 EMU_DST_HANA_ADAT + 6, EMU_SRC_ALICE_EMU32A + 6);
1217 emu->emu1010.output_source[22] = 27;
1219 EMU_DST_HANA_ADAT + 7, EMU_SRC_ALICE_EMU32A + 7);
1220 emu->emu1010.output_source[23] = 28;
1231 emu->emu1010.internal_clock = 1;
1244 #ifdef CONFIG_PM_SLEEP
1245 static int alloc_pm_buffer(
struct snd_emu10k1 *emu);
1246 static void free_pm_buffer(
struct snd_emu10k1 *emu);
1249 static int snd_emu10k1_free(
struct snd_emu10k1 *emu)
1256 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) {
1260 if (emu->emu1010.firmware_thread)
1265 if (emu->reserved_page) {
1268 emu->reserved_page =
NULL;
1272 if (emu->silent_page.area)
1274 if (emu->ptb_pages.area)
1276 vfree(emu->page_ptr_table);
1277 vfree(emu->page_addr_table);
1278 #ifdef CONFIG_PM_SLEEP
1279 free_pm_buffer(emu);
1283 if (emu->card_capabilities->ca0151_chip)
1293 return snd_emu10k1_free(emu);
1296 static struct snd_emu_chip_details emu_chip_details[] = {
1335 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10211102,
1336 .driver =
"Audigy2", .name =
"SB Audigy 4 [SB0610]",
1353 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102,
1354 .driver =
"Audigy2", .name =
"SB Audigy 2 Value [SB0400]",
1392 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102,
1393 .driver =
"Audigy2", .name =
"SB Audigy 2 ZS Notebook [SB0530]",
1397 .ca_cardbus_chip = 1,
1402 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102,
1403 .driver =
"Audigy2", .name =
"E-mu 1010 Notebook [MAEM8950]",
1407 .ca_cardbus_chip = 1,
1409 .emu_model = EMU_MODEL_EMU1616},
1412 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102,
1413 .driver =
"Audigy2", .name =
"E-mu 1010b PCI [MAEM8960]",
1418 .emu_model = EMU_MODEL_EMU1010B},
1421 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40071102,
1422 .driver =
"Audigy2", .name =
"E-mu 1010 PCIe [MAEM8986]",
1427 .emu_model = EMU_MODEL_EMU1010B},
1430 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
1431 .driver =
"Audigy2", .name =
"E-mu 1010 [MAEM8810]",
1436 .emu_model = EMU_MODEL_EMU1010},
1438 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40021102,
1439 .driver =
"Audigy2", .name =
"E-mu 0404b PCI [MAEM8852]",
1444 .emu_model = EMU_MODEL_EMU0404},
1446 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40021102,
1447 .driver =
"Audigy2", .name =
"E-mu 0404 [MAEM8850]",
1452 .emu_model = EMU_MODEL_EMU0404},
1454 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40051102,
1455 .driver =
"Audigy2", .name =
"E-mu 0404 PCIe [MAEM8984]",
1460 .emu_model = EMU_MODEL_EMU0404},
1462 {.vendor = 0x1102, .device = 0x0008,
1463 .driver =
"Audigy2", .name =
"SB Audigy 2 Value [Unknown]",
1469 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102,
1470 .driver =
"Audigy2", .name =
"SB Audigy 4 PRO [SB0380]",
1482 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102,
1483 .driver =
"Audigy2", .name =
"SB Audigy 2 [SB0350b]",
1490 .invert_shared_spdif = 1,
1494 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20051102,
1495 .driver =
"Audigy2", .name =
"SB Audigy 2 ZS [SB0350a]",
1502 .invert_shared_spdif = 1,
1504 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102,
1505 .driver =
"Audigy2", .name =
"SB Audigy 2 ZS [SB0350]",
1512 .invert_shared_spdif = 1,
1514 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102,
1515 .driver =
"Audigy2", .name =
"SB Audigy 2 ZS [SB0360]",
1522 .invert_shared_spdif = 1,
1532 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102,
1533 .driver =
"Audigy2", .name =
"SB Audigy 2 [SB0240]",
1542 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102,
1543 .driver =
"Audigy2", .name =
"SB Audigy 2 Platinum EX [SB0280]",
1552 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102,
1553 .driver =
"Audigy2", .name =
"SB Audigy 2 ZS [SB0353]",
1560 .invert_shared_spdif = 1,
1562 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
1563 .driver =
"Audigy2", .name =
"SB Audigy 2 Platinum [SB0240P]",
1570 .invert_shared_spdif = 1,
1573 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04,
1574 .driver =
"Audigy2", .name =
"SB Audigy 2 [Unknown]",
1581 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102,
1582 .driver =
"Audigy", .name =
"SB Audigy 1 [SB0092]",
1587 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102,
1588 .driver =
"Audigy", .name =
"SB Audigy 1 ES [SB0160]",
1594 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102,
1595 .driver =
"Audigy", .name =
"SB Audigy 1 [SB0090]",
1600 {.vendor = 0x1102, .device = 0x0004,
1601 .driver =
"Audigy", .name =
"Audigy 1 [Unknown]",
1606 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102,
1607 .driver =
"EMU10K1", .name =
"SB Live! 5.1 [SB0220]",
1612 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806b1102,
1613 .driver =
"EMU10K1", .name =
"SB Live! [SB0105]",
1618 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806a1102,
1619 .driver =
"EMU10K1", .name =
"SB Live! Value [SB0103]",
1624 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102,
1625 .driver =
"EMU10K1", .name =
"SB Live! Value [SB0101]",
1633 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102,
1634 .driver =
"EMU10K1", .name =
"SB Live! 5.1 Dell OEM [SB0228]",
1640 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102,
1641 .driver =
"EMU10K1", .name =
"SB Live! 5.1 [SB0220]",
1646 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102,
1647 .driver =
"EMU10K1", .name =
"SB Live! 5.1",
1653 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
1654 .driver =
"EMU10K1", .name =
"SB Live! 5.1 [SB0060]",
1661 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102,
1662 .driver =
"EMU10K1", .name =
"SB Live! Value [CT4850]",
1667 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102,
1668 .driver =
"EMU10K1", .name =
"SB Live! Platinum [CT4760P]",
1672 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102,
1673 .driver =
"EMU10K1", .name =
"SB Live! Value [CT4871]",
1678 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102,
1679 .driver =
"EMU10K1", .name =
"SB Live! Value [CT4831]",
1684 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102,
1685 .driver =
"EMU10K1", .name =
"SB Live! Value [CT4870]",
1691 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102,
1692 .driver =
"EMU10K1", .name =
"SB Live! Value [CT4832]",
1697 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102,
1698 .driver =
"EMU10K1", .name =
"SB Live! Value [CT4830]",
1703 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102,
1704 .driver =
"EMU10K1", .name =
"SB PCI512 [CT4790]",
1709 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102,
1710 .driver =
"EMU10K1", .name =
"SB Live! Value [CT4780]",
1715 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102,
1716 .driver =
"EMU10K1", .name =
"E-mu APS [PC545]",
1720 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102,
1721 .driver =
"EMU10K1", .name =
"SB Live! [CT4620]",
1726 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102,
1727 .driver =
"EMU10K1", .name =
"SB Live! Value [CT4670]",
1732 {.vendor = 0x1102, .device = 0x0002,
1733 .driver =
"EMU10K1", .name =
"SB Live! [Unknown]",
1743 unsigned short extin_mask,
1744 unsigned short extout_mask,
1745 long max_cache_bytes,
1748 struct snd_emu10k1 **remu)
1750 struct snd_emu10k1 *emu;
1753 unsigned int silent_page;
1754 const struct snd_emu_chip_details *
c;
1756 .dev_free = snd_emu10k1_dev_free,
1780 INIT_LIST_HEAD(&emu->mapped_link_head);
1781 INIT_LIST_HEAD(&emu->mapped_order_link_head);
1785 emu->get_synth_voice =
NULL;
1790 snd_printdd(
"vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n", pci->
vendor, pci->
device, emu->serial, emu->model);
1792 for (c = emu_chip_details; c->vendor; c++) {
1793 if (c->vendor == pci->
vendor && c->device == pci->
device) {
1795 if (c->subsystem && (c->subsystem == subsystem))
1800 if (c->subsystem && (c->subsystem != emu->serial))
1802 if (c->revision && c->revision != emu->revision)
1808 if (c->vendor == 0) {
1814 emu->card_capabilities =
c;
1815 if (c->subsystem && !subsystem)
1819 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. "
1820 "Forced to subsystem = 0x%x\n", c->name,
1824 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n",
1828 if (!*card->
id && c->id) {
1836 if (i >= snd_ecards_limit)
1841 snprintf(card->
id,
sizeof(card->
id),
"%s_%d", c->id, n);
1845 is_audigy = emu->audigy = c->emu10k2_chip;
1848 emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
1849 if (pci_set_dma_mask(pci, emu->
dma_mask) < 0 ||
1850 pci_set_consistent_dma_mask(pci, emu->
dma_mask) < 0) {
1851 snd_printk(
KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask);
1857 emu->gpr_base = A_FXGPREGBASE;
1859 emu->gpr_base = FXGPREGBASE;
1869 emu->max_cache_pages = max_cache_bytes >>
PAGE_SHIFT;
1871 32 * 1024, &emu->ptb_pages) < 0) {
1876 emu->page_ptr_table =
vmalloc(emu->max_cache_pages *
sizeof(
void *));
1877 emu->page_addr_table =
vmalloc(emu->max_cache_pages *
1878 sizeof(
unsigned long));
1879 if (emu->page_ptr_table ==
NULL || emu->page_addr_table ==
NULL) {
1885 EMUPAGESIZE, &emu->silent_page) < 0) {
1890 if (emu->memhdr ==
NULL) {
1894 emu->memhdr->block_extra_size =
sizeof(
struct snd_emu10k1_memblk) -
1899 emu->fx8010.fxbus_mask = 0x303f;
1900 if (extin_mask == 0)
1901 extin_mask = 0x3fcf;
1902 if (extout_mask == 0)
1903 extout_mask = 0x7fff;
1904 emu->fx8010.extin_mask = extin_mask;
1905 emu->fx8010.extout_mask = extout_mask;
1906 emu->enable_ir = enable_ir;
1908 if (emu->card_capabilities->ca_cardbus_chip) {
1909 err = snd_emu10k1_cardbus_init(emu);
1913 if (emu->card_capabilities->ecard) {
1914 err = snd_emu10k1_ecard_init(emu);
1917 }
else if (emu->card_capabilities->emu_model) {
1918 err = snd_emu10k1_emu1010_init(emu);
1920 snd_emu10k1_free(emu);
1927 AC97SLOT_CNTR|AC97SLOT_LFE);
1931 emu->fx8010.itram_size = (16 * 1024)/2;
1932 emu->fx8010.etram_pages.area =
NULL;
1933 emu->fx8010.etram_pages.bytes = 0;
1937 KBUILD_MODNAME, emu)) {
1941 emu->irq = pci->
irq;
1957 emu->spdif_bits[0] = emu->spdif_bits[1] =
1963 emu->reserved_page = (
struct snd_emu10k1_memblk *)
1965 if (emu->reserved_page)
1966 emu->reserved_page->map_locked = 1;
1970 silent_page = emu->silent_page.addr << 1;
1971 for (idx = 0; idx < MAXPAGES; idx++)
1975 for (idx = 0; idx < NUM_G; idx++) {
1976 emu->voices[
idx].emu = emu;
1977 emu->voices[
idx].number =
idx;
1980 err = snd_emu10k1_init(emu, enable_ir, 0);
1983 #ifdef CONFIG_PM_SLEEP
1984 err = alloc_pm_buffer(emu);
1993 snd_emu10k1_audio_enable(emu);
1999 #ifdef CONFIG_PROC_FS
2000 snd_emu10k1_proc_init(emu);
2008 snd_emu10k1_free(emu);
2012 #ifdef CONFIG_PM_SLEEP
2014 CPF, PTRX, CVCF, VTFT, Z1, Z2, PSST,
DSL, CCCA,
CCR, CLP,
2015 FXRT, MAPA, MAPB, ENVVOL, ATKHLDV, DCYSUSV, LFOVAL1, ENVVAL,
2016 ATKHLDM, DCYSUSM, LFOVAL2,
IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2,
2017 TEMPENV, ADCCR, FXWC, MICBA, ADCBA, FXBA,
2019 SPBYPASS, AC97SLOT, CDSRCS, GPSRCS, ZVSRCS, MICIDX, ADCIDX, FXIDX,
2022 static unsigned char saved_regs_audigy[] = {
2023 A_ADCIDX, A_MICIDX, A_FXWC1, A_FXWC2, A_SAMPLE_RATE,
2024 A_FXRT2, A_SENDAMOUNTS, A_FXRT1,
2028 static int __devinit alloc_pm_buffer(
struct snd_emu10k1 *emu)
2035 emu->saved_ptr =
vmalloc(4 * NUM_G * size);
2036 if (!emu->saved_ptr)
2038 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0)
2040 if (emu->card_capabilities->ca0151_chip &&
2041 snd_p16v_alloc_pm_buffer(emu) < 0)
2046 static void free_pm_buffer(
struct snd_emu10k1 *emu)
2048 vfree(emu->saved_ptr);
2049 snd_emu10k1_efx_free_pm_buffer(emu);
2050 if (emu->card_capabilities->ca0151_chip)
2051 snd_p16v_free_pm_buffer(emu);
2054 void snd_emu10k1_suspend_regs(
struct snd_emu10k1 *emu)
2060 val = emu->saved_ptr;
2061 for (reg = saved_regs; *reg != 0xff; reg++)
2062 for (i = 0; i < NUM_G; i++, val++)
2065 for (reg = saved_regs_audigy; *reg != 0xff; reg++)
2066 for (i = 0; i < NUM_G; i++, val++)
2070 emu->saved_a_iocfg =
inl(emu->port + A_IOCFG);
2071 emu->saved_hcfg =
inl(emu->port +
HCFG);
2074 void snd_emu10k1_resume_init(
struct snd_emu10k1 *emu)
2076 if (emu->card_capabilities->ca_cardbus_chip)
2077 snd_emu10k1_cardbus_init(emu);
2078 if (emu->card_capabilities->ecard)
2079 snd_emu10k1_ecard_init(emu);
2080 else if (emu->card_capabilities->emu_model)
2081 snd_emu10k1_emu1010_init(emu);
2084 snd_emu10k1_init(emu, emu->enable_ir, 1);
2087 void snd_emu10k1_resume_regs(
struct snd_emu10k1 *emu)
2093 snd_emu10k1_audio_enable(emu);
2097 outl(emu->saved_a_iocfg, emu->port + A_IOCFG);
2098 outl(emu->saved_hcfg, emu->port +
HCFG);
2100 val = emu->saved_ptr;
2101 for (reg = saved_regs; *reg != 0xff; reg++)
2102 for (i = 0; i < NUM_G; i++, val++)
2105 for (reg = saved_regs_audigy; *reg != 0xff; reg++)
2106 for (i = 0; i < NUM_G; i++, val++)