📄 emu10k1_main.c
字号:
snd_emu10k1_ptr_write(emu, MICBS, 0, 0); snd_emu10k1_ptr_write(emu, MICBA, 0, 0); snd_emu10k1_ptr_write(emu, FXBS, 0, 0); snd_emu10k1_ptr_write(emu, FXBA, 0, 0); snd_emu10k1_ptr_write(emu, FXWC, 0, 0); snd_emu10k1_ptr_write(emu, ADCBS, 0, ADCBS_BUFSIZE_NONE); snd_emu10k1_ptr_write(emu, ADCBA, 0, 0); snd_emu10k1_ptr_write(emu, TCBS, 0, TCBS_BUFFSIZE_16K); snd_emu10k1_ptr_write(emu, TCB, 0, 0); if (emu->audigy) snd_emu10k1_ptr_write(emu, A_DBG, 0, A_DBG_SINGLE_STEP); else snd_emu10k1_ptr_write(emu, DBG, 0, EMU10K1_DBG_SINGLE_STEP); /* disable channel interrupt */ snd_emu10k1_ptr_write(emu, CLIEL, 0, 0); snd_emu10k1_ptr_write(emu, CLIEH, 0, 0); snd_emu10k1_ptr_write(emu, SOLEL, 0, 0); snd_emu10k1_ptr_write(emu, SOLEH, 0, 0); /* remove reserved page */ if (emu->reserved_page != NULL) { snd_emu10k1_synth_free(emu, (snd_util_memblk_t *)emu->reserved_page); emu->reserved_page = NULL; } /* disable audio and lock cache */ outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG); snd_emu10k1_ptr_write(emu, PTB, 0, 0); snd_emu10k1_free_efx(emu); return 0;}/************************************************************************* * ECARD functional implementation *************************************************************************//* In A1 Silicon, these bits are in the HC register */#define HOOKN_BIT (1L << 12)#define HANDN_BIT (1L << 11)#define PULSEN_BIT (1L << 10)#define EC_GDI1 (1 << 13)#define EC_GDI0 (1 << 14)#define EC_NUM_CONTROL_BITS 20#define EC_AC3_DATA_SELN 0x0001L#define EC_EE_DATA_SEL 0x0002L#define EC_EE_CNTRL_SELN 0x0004L#define EC_EECLK 0x0008L#define EC_EECS 0x0010L#define EC_EESDO 0x0020L#define EC_TRIM_CSN 0x0040L#define EC_TRIM_SCLK 0x0080L#define EC_TRIM_SDATA 0x0100L#define EC_TRIM_MUTEN 0x0200L#define EC_ADCCAL 0x0400L#define EC_ADCRSTN 0x0800L#define EC_DACCAL 0x1000L#define EC_DACMUTEN 0x2000L#define EC_LEDN 0x4000L#define EC_SPDIF0_SEL_SHIFT 15#define EC_SPDIF1_SEL_SHIFT 17#define EC_SPDIF0_SEL_MASK (0x3L << EC_SPDIF0_SEL_SHIFT)#define EC_SPDIF1_SEL_MASK (0x7L << EC_SPDIF1_SEL_SHIFT)#define EC_SPDIF0_SELECT(_x) (((_x) << EC_SPDIF0_SEL_SHIFT) & EC_SPDIF0_SEL_MASK)#define EC_SPDIF1_SELECT(_x) (((_x) << EC_SPDIF1_SEL_SHIFT) & EC_SPDIF1_SEL_MASK)#define EC_CURRENT_PROM_VERSION 0x01 /* Self-explanatory. This should * be incremented any time the EEPROM's * format is changed. */#define EC_EEPROM_SIZE 0x40 /* ECARD EEPROM has 64 16-bit words *//* Addresses for special values stored in to EEPROM */#define EC_PROM_VERSION_ADDR 0x20 /* Address of the current prom version */#define EC_BOARDREV0_ADDR 0x21 /* LSW of board rev */#define EC_BOARDREV1_ADDR 0x22 /* MSW of board rev */#define EC_LAST_PROMFILE_ADDR 0x2f#define EC_SERIALNUM_ADDR 0x30 /* First word of serial number. The * can be up to 30 characters in length * and is stored as a NULL-terminated * ASCII string. Any unused bytes must be * filled with zeros */#define EC_CHECKSUM_ADDR 0x3f /* Location at which checksum is stored *//* Most of this stuff is pretty self-evident. According to the hardware * dudes, we need to leave the ADCCAL bit low in order to avoid a DC * offset problem. Weird. */#define EC_RAW_RUN_MODE (EC_DACMUTEN | EC_ADCRSTN | EC_TRIM_MUTEN | \ EC_TRIM_CSN)#define EC_DEFAULT_ADC_GAIN 0xC4C4#define EC_DEFAULT_SPDIF0_SEL 0x0#define EC_DEFAULT_SPDIF1_SEL 0x4/************************************************************************** * @func Clock bits into the Ecard's control latch. The Ecard uses a * control latch will is loaded bit-serially by toggling the Modem control * lines from function 2 on the E8010. This function hides these details * and presents the illusion that we are actually writing to a distinct * register. */static void snd_emu10k1_ecard_write(emu10k1_t * emu, unsigned int value){ unsigned short count; unsigned int data; unsigned long hc_port; unsigned int hc_value; hc_port = emu->port + HCFG; hc_value = inl(hc_port) & ~(HOOKN_BIT | HANDN_BIT | PULSEN_BIT); outl(hc_value, hc_port); for (count = 0; count < EC_NUM_CONTROL_BITS; count++) { /* Set up the value */ data = ((value & 0x1) ? PULSEN_BIT : 0); value >>= 1; outl(hc_value | data, hc_port); /* Clock the shift register */ outl(hc_value | data | HANDN_BIT, hc_port); outl(hc_value | data, hc_port); } /* Latch the bits */ outl(hc_value | HOOKN_BIT, hc_port); outl(hc_value, hc_port);}/************************************************************************** * @func Set the gain of the ECARD's CS3310 Trim/gain controller. The * trim value consists of a 16bit value which is composed of two * 8 bit gain/trim values, one for the left channel and one for the * right channel. The following table maps from the Gain/Attenuation * value in decibels into the corresponding bit pattern for a single * channel. */static void snd_emu10k1_ecard_setadcgain(emu10k1_t * emu, unsigned short gain){ unsigned int bit; /* Enable writing to the TRIM registers */ snd_emu10k1_ecard_write(emu, emu->ecard_ctrl & ~EC_TRIM_CSN); /* Do it again to insure that we meet hold time requirements */ snd_emu10k1_ecard_write(emu, emu->ecard_ctrl & ~EC_TRIM_CSN); for (bit = (1 << 15); bit; bit >>= 1) { unsigned int value; value = emu->ecard_ctrl & ~(EC_TRIM_CSN | EC_TRIM_SDATA); if (gain & bit) value |= EC_TRIM_SDATA; /* Clock the bit */ snd_emu10k1_ecard_write(emu, value); snd_emu10k1_ecard_write(emu, value | EC_TRIM_SCLK); snd_emu10k1_ecard_write(emu, value); } snd_emu10k1_ecard_write(emu, emu->ecard_ctrl);}static int __devinit snd_emu10k1_ecard_init(emu10k1_t * emu){ unsigned int hc_value; /* Set up the initial settings */ emu->ecard_ctrl = EC_RAW_RUN_MODE | EC_SPDIF0_SELECT(EC_DEFAULT_SPDIF0_SEL) | EC_SPDIF1_SELECT(EC_DEFAULT_SPDIF1_SEL); /* Step 0: Set the codec type in the hardware control register * and enable audio output */ hc_value = inl(emu->port + HCFG); outl(hc_value | HCFG_AUDIOENABLE | HCFG_CODECFORMAT_I2S, emu->port + HCFG); inl(emu->port + HCFG); /* Step 1: Turn off the led and deassert TRIM_CS */ snd_emu10k1_ecard_write(emu, EC_ADCCAL | EC_LEDN | EC_TRIM_CSN); /* Step 2: Calibrate the ADC and DAC */ snd_emu10k1_ecard_write(emu, EC_DACCAL | EC_LEDN | EC_TRIM_CSN); /* Step 3: Wait for awhile; XXX We can't get away with this * under a real operating system; we'll need to block and wait that * way. */ snd_emu10k1_wait(emu, 48000); /* Step 4: Switch off the DAC and ADC calibration. Note * That ADC_CAL is actually an inverted signal, so we assert * it here to stop calibration. */ snd_emu10k1_ecard_write(emu, EC_ADCCAL | EC_LEDN | EC_TRIM_CSN); /* Step 4: Switch into run mode */ snd_emu10k1_ecard_write(emu, emu->ecard_ctrl); /* Step 5: Set the analog input gain */ snd_emu10k1_ecard_setadcgain(emu, EC_DEFAULT_ADC_GAIN); return 0;}static int __devinit snd_emu10k1_cardbus_init(emu10k1_t * emu){ unsigned long special_port; unsigned int value; /* Special initialisation routine * before the rest of the IO-Ports become active. */ special_port = emu->port + 0x38; value = inl(special_port); outl(0x00d00000, special_port); value = inl(special_port); outl(0x00d00001, special_port); value = inl(special_port); outl(0x00d0005f, special_port); value = inl(special_port); outl(0x00d0007f, special_port); value = inl(special_port); outl(0x0090007f, special_port); value = inl(special_port); return 0;}/* * Create the EMU10K1 instance */static int snd_emu10k1_free(emu10k1_t *emu){ if (emu->port) { /* avoid access to already used hardware */ snd_emu10k1_fx8010_tram_setup(emu, 0); snd_emu10k1_done(emu); } if (emu->memhdr) snd_util_memhdr_free(emu->memhdr); if (emu->silent_page.area) snd_dma_free_pages(&emu->silent_page); if (emu->ptb_pages.area) snd_dma_free_pages(&emu->ptb_pages); vfree(emu->page_ptr_table); vfree(emu->page_addr_table); if (emu->irq >= 0) free_irq(emu->irq, (void *)emu); if (emu->port) pci_release_regions(emu->pci); pci_disable_device(emu->pci); if (emu->card_capabilities->ca0151_chip) /* P16V */ snd_p16v_free(emu); kfree(emu); return 0;}static int snd_emu10k1_dev_free(snd_device_t *device){ emu10k1_t *emu = device->device_data; return snd_emu10k1_free(emu);}static emu_chip_details_t emu_chip_details[] = { /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ /* Tested by James@superbug.co.uk 3rd July 2005 */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", .id = "Audigy2", .emu10k2_chip = 1, .ca0108_chip = 1, .spk71 = 1, .ac97_chip = 1} , /* Audigy 2 ZS Notebook Cardbus card.*/ /* Tested by James@superbug.co.uk 30th October 2005 */ /* Not working yet, but progressing. */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", .id = "Audigy2", .emu10k2_chip = 1, .ca0108_chip = 1, .ca_cardbus_chip = 1, .spk71 = 1} , {.vendor = 0x1102, .device = 0x0008, .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", .id = "Audigy2", .emu10k2_chip = 1, .ca0108_chip = 1, .ac97_chip = 1} , /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, .driver = "Audigy2", .name = "E-mu 1212m [4001]", .id = "EMU1212m", .emu10k2_chip = 1, .ca0102_chip = 1, .ecard = 1} , /* Tested by James@superbug.co.uk 3rd July 2005 */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", .id = "Audigy2", .emu10k2_chip = 1, .ca0102_chip = 1, .ca0151_chip = 1, .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", .id = "Audigy2", .emu10k2_chip = 1, .ca0102_chip = 1, .ca0151_chip = 1, .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", .id = "Audigy2", .emu10k2_chip = 1, .ca0102_chip = 1, .ca0151_chip = 1, .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, .driver = "Audigy2", .name = "Audigy 2 [SB0240]", .id = "Audigy2", .emu10k2_chip = 1, .ca0102_chip = 1, .ca0151_chip = 1, .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, .driver = "Audigy2", .name = "Audigy 2 EX [1005]", .id = "Audigy2", .emu10k2_chip = 1, .ca0102_chip = 1, .ca0151_chip = 1, .spdif_bug = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", .id = "Audigy2", .emu10k2_chip = 1, .ca0102_chip = 1, .ca0151_chip = 1, .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} ,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -