aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/emu10k1/emu10k1_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/emu10k1/emu10k1_main.c')
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c540
1 files changed, 418 insertions, 122 deletions
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 972ec40d8166..891172f2b1d7 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -3,8 +3,10 @@
3 * Creative Labs, Inc. 3 * Creative Labs, Inc.
4 * Routines for control of EMU10K1 chips 4 * Routines for control of EMU10K1 chips
5 * 5 *
6 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> 6 * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
7 * Added support for Audigy 2 Value. 7 * Added support for Audigy 2 Value.
8 * Added EMU 1010 support.
9 * General bug fixes and enhancements.
8 * 10 *
9 * 11 *
10 * BUGS: 12 * BUGS:
@@ -41,6 +43,7 @@
41 43
42#include <sound/core.h> 44#include <sound/core.h>
43#include <sound/emu10k1.h> 45#include <sound/emu10k1.h>
46#include <linux/firmware.h>
44#include "p16v.h" 47#include "p16v.h"
45#include "tina2.h" 48#include "tina2.h"
46 49
@@ -211,7 +214,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
211 int size, n; 214 int size, n;
212 215
213 size = ARRAY_SIZE(spi_dac_init); 216 size = ARRAY_SIZE(spi_dac_init);
214 for (n=0; n < size; n++) 217 for (n = 0; n < size; n++)
215 snd_emu10k1_spi_write(emu, spi_dac_init[n]); 218 snd_emu10k1_spi_write(emu, spi_dac_init[n]);
216 219
217 snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10); 220 snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10);
@@ -239,6 +242,10 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
239 snd_emu10k1_ptr_write(emu, MAPB, ch, silent_page); 242 snd_emu10k1_ptr_write(emu, MAPB, ch, silent_page);
240 } 243 }
241 244
245 if (emu->card_capabilities->emu1010) {
246 outl(HCFG_AUTOMUTE_ASYNC |
247 HCFG_EMU32_SLAVE |
248 HCFG_AUDIOENABLE, emu->port + HCFG);
242 /* 249 /*
243 * Hokay, setup HCFG 250 * Hokay, setup HCFG
244 * Mute Disable Audio = 0 251 * Mute Disable Audio = 0
@@ -246,7 +253,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
246 * Lock Sound Memory = 0 253 * Lock Sound Memory = 0
247 * Auto Mute = 1 254 * Auto Mute = 1
248 */ 255 */
249 if (emu->audigy) { 256 } else if (emu->audigy) {
250 if (emu->revision == 4) /* audigy2 */ 257 if (emu->revision == 4) /* audigy2 */
251 outl(HCFG_AUDIOENABLE | 258 outl(HCFG_AUDIOENABLE |
252 HCFG_AC3ENABLE_CDSPDIF | 259 HCFG_AC3ENABLE_CDSPDIF |
@@ -265,8 +272,8 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
265 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); 272 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
266 273
267 if (enable_ir) { /* enable IR for SB Live */ 274 if (enable_ir) { /* enable IR for SB Live */
268 if ( emu->card_capabilities->emu1212m) { 275 if (emu->card_capabilities->emu1010) {
269 ; /* Disable all access to A_IOCFG for the emu1212m */ 276 ; /* Disable all access to A_IOCFG for the emu1010 */
270 } else if (emu->audigy) { 277 } else if (emu->audigy) {
271 unsigned int reg = inl(emu->port + A_IOCFG); 278 unsigned int reg = inl(emu->port + A_IOCFG);
272 outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG); 279 outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG);
@@ -284,8 +291,8 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
284 } 291 }
285 } 292 }
286 293
287 if ( emu->card_capabilities->emu1212m) { 294 if (emu->card_capabilities->emu1010) {
288 ; /* Disable all access to A_IOCFG for the emu1212m */ 295 ; /* Disable all access to A_IOCFG for the emu1010 */
289 } else if (emu->audigy) { /* enable analog output */ 296 } else if (emu->audigy) { /* enable analog output */
290 unsigned int reg = inl(emu->port + A_IOCFG); 297 unsigned int reg = inl(emu->port + A_IOCFG);
291 outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG); 298 outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG);
@@ -302,8 +309,8 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu)
302 outl(inl(emu->port + HCFG) | HCFG_AUDIOENABLE, emu->port + HCFG); 309 outl(inl(emu->port + HCFG) | HCFG_AUDIOENABLE, emu->port + HCFG);
303 310
304 /* Enable analog/digital outs on audigy */ 311 /* Enable analog/digital outs on audigy */
305 if ( emu->card_capabilities->emu1212m) { 312 if (emu->card_capabilities->emu1010) {
306 ; /* Disable all access to A_IOCFG for the emu1212m */ 313 ; /* Disable all access to A_IOCFG for the emu1010 */
307 } else if (emu->audigy) { 314 } else if (emu->audigy) {
308 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); 315 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG);
309 316
@@ -596,133 +603,417 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu)
596 return 0; 603 return 0;
597} 604}
598 605
599static int snd_emu1212m_fpga_write(struct snd_emu10k1 * emu, int reg, int value) 606static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename)
600{
601 if (reg<0 || reg>0x3f)
602 return 1;
603 reg+=0x40; /* 0x40 upwards are registers. */
604 if (value<0 || value>0x3f) /* 0 to 0x3f are values */
605 return 1;
606 outl(reg, emu->port + A_IOCFG);
607 outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */
608 outl(value, emu->port + A_IOCFG);
609 outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */
610
611 return 0;
612}
613
614static int snd_emu1212m_fpga_read(struct snd_emu10k1 * emu, int reg, int *value)
615{ 607{
616 if (reg<0 || reg>0x3f) 608 int err;
617 return 1; 609 int n, i;
618 reg+=0x40; /* 0x40 upwards are registers. */ 610 int reg;
619 outl(reg, emu->port + A_IOCFG); 611 int value;
620 outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ 612 const struct firmware *fw_entry;
621 *value = inl(emu->port + A_IOCFG); 613
622 614 if ((err = request_firmware(&fw_entry, filename, &emu->pci->dev)) != 0) {
623 return 0; 615 snd_printk(KERN_ERR "firmware: %s not found. Err=%d\n",filename, err);
624} 616 return err;
617 }
618 snd_printk(KERN_INFO "firmware size=0x%x\n",fw_entry->size);
619 if (fw_entry->size != 0x133a4) {
620 snd_printk(KERN_ERR "firmware: %s wrong size.\n",filename);
621 return -EINVAL;
622 }
625 623
626static int snd_emu1212m_fpga_netlist_write(struct snd_emu10k1 * emu, int reg, int value) 624 /* The FPGA is a Xilinx Spartan IIE XC2S50E */
627{ 625 /* GPIO7 -> FPGA PGMN
628 snd_emu1212m_fpga_write(emu, 0x00, ((reg >> 8) & 0x3f) ); 626 * GPIO6 -> FPGA CCLK
629 snd_emu1212m_fpga_write(emu, 0x01, (reg & 0x3f) ); 627 * GPIO5 -> FPGA DIN
630 snd_emu1212m_fpga_write(emu, 0x02, ((value >> 8) & 0x3f) ); 628 * FPGA CONFIG OFF -> FPGA PGMN
631 snd_emu1212m_fpga_write(emu, 0x03, (value & 0x3f) ); 629 */
630 outl(0x00, emu->port + A_IOCFG); /* Set PGMN low for 1uS. */
631 udelay(1);
632 outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */
633 udelay(100); /* Allow FPGA memory to clean */
634 for(n = 0; n < fw_entry->size; n++) {
635 value=fw_entry->data[n];
636 for(i = 0; i < 8; i++) {
637 reg = 0x80;
638 if (value & 0x1)
639 reg = reg | 0x20;
640 value = value >> 1;
641 outl(reg, emu->port + A_IOCFG);
642 outl(reg | 0x40, emu->port + A_IOCFG);
643 }
644 }
645 /* After programming, set GPIO bit 4 high again. */
646 outl(0x10, emu->port + A_IOCFG);
647
632 648
649 release_firmware(fw_entry);
633 return 0; 650 return 0;
634} 651}
635 652
636static int snd_emu10k1_emu1212m_init(struct snd_emu10k1 * emu) 653static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
637{ 654{
638 unsigned int i; 655 unsigned int i;
639 int tmp; 656 int tmp,tmp2;
640 657 int reg;
641 snd_printk(KERN_ERR "emu1212m: Special config.\n"); 658 int err;
659 const char *hana_filename = "emu/hana.fw";
660 const char *dock_filename = "emu/audio_dock.fw";
661
662 snd_printk(KERN_INFO "emu1010: Special config.\n");
663 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
664 * Lock Sound Memory Cache, Lock Tank Memory Cache,
665 * Mute all codecs.
666 */
642 outl(0x0005a00c, emu->port + HCFG); 667 outl(0x0005a00c, emu->port + HCFG);
643 outl(0x0005a004, emu->port + HCFG); 668 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
669 * Lock Tank Memory Cache,
670 * Mute all codecs.
671 */
672 outl(0x0005a004, emu->port + HCFG);
673 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
674 * Mute all codecs.
675 */
644 outl(0x0005a000, emu->port + HCFG); 676 outl(0x0005a000, emu->port + HCFG);
677 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
678 * Mute all codecs.
679 */
645 outl(0x0005a000, emu->port + HCFG); 680 outl(0x0005a000, emu->port + HCFG);
646 681
647 snd_emu1212m_fpga_read(emu, 0x22, &tmp ); 682 /* Disable 48Volt power to Audio Dock */
648 snd_emu1212m_fpga_read(emu, 0x23, &tmp ); 683 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 );
649 snd_emu1212m_fpga_read(emu, 0x24, &tmp ); 684
650 snd_emu1212m_fpga_write(emu, 0x04, 0x01 ); 685 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */
651 snd_emu1212m_fpga_read(emu, 0x0b, &tmp ); 686 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
652 snd_emu1212m_fpga_write(emu, 0x0b, 0x01 ); 687 snd_printdd("reg1=0x%x\n",reg);
653 snd_emu1212m_fpga_read(emu, 0x10, &tmp ); 688 if (reg == 0x55) {
654 snd_emu1212m_fpga_write(emu, 0x10, 0x00 ); 689 /* FPGA netlist already present so clear it */
655 snd_emu1212m_fpga_read(emu, 0x11, &tmp ); 690 /* Return to programming mode */
656 snd_emu1212m_fpga_write(emu, 0x11, 0x30 ); 691
657 snd_emu1212m_fpga_read(emu, 0x13, &tmp ); 692 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02 );
658 snd_emu1212m_fpga_write(emu, 0x13, 0x0f );
659 snd_emu1212m_fpga_read(emu, 0x11, &tmp );
660 snd_emu1212m_fpga_write(emu, 0x11, 0x30 );
661 snd_emu1212m_fpga_read(emu, 0x0a, &tmp );
662 snd_emu1212m_fpga_write(emu, 0x0a, 0x10 );
663 snd_emu1212m_fpga_write(emu, 0x0c, 0x19 );
664 snd_emu1212m_fpga_write(emu, 0x12, 0x0c );
665 snd_emu1212m_fpga_write(emu, 0x09, 0x0f );
666 snd_emu1212m_fpga_write(emu, 0x06, 0x00 );
667 snd_emu1212m_fpga_write(emu, 0x05, 0x00 );
668 snd_emu1212m_fpga_write(emu, 0x0e, 0x12 );
669 snd_emu1212m_fpga_netlist_write(emu, 0x0000, 0x0200);
670 snd_emu1212m_fpga_netlist_write(emu, 0x0001, 0x0201);
671 snd_emu1212m_fpga_netlist_write(emu, 0x0002, 0x0500);
672 snd_emu1212m_fpga_netlist_write(emu, 0x0003, 0x0501);
673 snd_emu1212m_fpga_netlist_write(emu, 0x0004, 0x0400);
674 snd_emu1212m_fpga_netlist_write(emu, 0x0005, 0x0401);
675 snd_emu1212m_fpga_netlist_write(emu, 0x0006, 0x0402);
676 snd_emu1212m_fpga_netlist_write(emu, 0x0007, 0x0403);
677 snd_emu1212m_fpga_netlist_write(emu, 0x0008, 0x0404);
678 snd_emu1212m_fpga_netlist_write(emu, 0x0009, 0x0405);
679 snd_emu1212m_fpga_netlist_write(emu, 0x000a, 0x0406);
680 snd_emu1212m_fpga_netlist_write(emu, 0x000b, 0x0407);
681 snd_emu1212m_fpga_netlist_write(emu, 0x000c, 0x0100);
682 snd_emu1212m_fpga_netlist_write(emu, 0x000d, 0x0104);
683 snd_emu1212m_fpga_netlist_write(emu, 0x000e, 0x0200);
684 snd_emu1212m_fpga_netlist_write(emu, 0x000f, 0x0201);
685 for (i=0;i < 0x20;i++) {
686 snd_emu1212m_fpga_netlist_write(emu, 0x0100+i, 0x0000);
687 } 693 }
688 for (i=0;i < 4;i++) { 694 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
689 snd_emu1212m_fpga_netlist_write(emu, 0x0200+i, 0x0000); 695 snd_printdd("reg2=0x%x\n",reg);
696 if (reg == 0x55) {
697 /* FPGA failed to return to programming mode */
698 return -ENODEV;
690 } 699 }
691 for (i=0;i < 7;i++) { 700 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg);
692 snd_emu1212m_fpga_netlist_write(emu, 0x0300+i, 0x0000); 701 if ((err = snd_emu1010_load_firmware(emu, hana_filename)) != 0) {
702 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", hana_filename);
703 return err;
693 } 704 }
694 for (i=0;i < 7;i++) { 705
695 snd_emu1212m_fpga_netlist_write(emu, 0x0400+i, 0x0000); 706 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
707 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
708 if (reg != 0x55) {
709 /* FPGA failed to be programmed */
710 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg);
711 return -ENODEV;
696 } 712 }
697 snd_emu1212m_fpga_netlist_write(emu, 0x0500, 0x0108);
698 snd_emu1212m_fpga_netlist_write(emu, 0x0501, 0x010c);
699 snd_emu1212m_fpga_netlist_write(emu, 0x0600, 0x0110);
700 snd_emu1212m_fpga_netlist_write(emu, 0x0601, 0x0114);
701 snd_emu1212m_fpga_netlist_write(emu, 0x0700, 0x0118);
702 snd_emu1212m_fpga_netlist_write(emu, 0x0701, 0x011c);
703 snd_emu1212m_fpga_write(emu, 0x07, 0x01 );
704 713
705 snd_emu1212m_fpga_read(emu, 0x21, &tmp ); 714 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n");
715 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp );
716 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2 );
717 snd_printk("Hana ver:%d.%d\n",tmp ,tmp2);
718 /* Enable 48Volt power to Audio Dock */
719 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON );
720
721 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg );
722 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg);
723 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg );
724 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg);
725 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp );
726 /* ADAT input. */
727 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x01 );
728 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_PADS, &tmp );
729 /* Set no attenuation on Audio Dock pads. */
730 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PADS, 0x00 );
731 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp );
732 /* Unmute Audio dock DACs, Headphone source DAC-4. */
733 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 );
734 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 );
735 snd_emu1010_fpga_read(emu, EMU_HANA_UNKNOWN13, &tmp );
736 /* Unknown. */
737 snd_emu1010_fpga_write(emu, EMU_HANA_UNKNOWN13, 0x0f );
738 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp );
739 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 );
740 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp );
741 /* SPDIF Format. Set Consumer mode, 24bit, copy enable */
742 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 );
743 /* MIDI routing */
744 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI, 0x19 );
745 /* Unknown. */
746 snd_emu1010_fpga_write(emu, EMU_HANA_UNKNOWN12, 0x0c );
747 /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); // IRQ Enable: All on */
748 /* IRQ Enable: All off */
749 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00 );
750
751 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg );
752 snd_printk(KERN_INFO "emu1010: Card options3=0x%x\n",reg);
753 /* Default WCLK set to 48kHz. */
754 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00 );
755 /* Word Clock source, Internal 48kHz x1 */
756 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K );
757 //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X );
758 /* Audio Dock LEDs. */
759 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 );
706 760
707 outl(0x0000a000, emu->port + HCFG); 761#if 0
762 /* For 96kHz */
763 snd_emu1010_fpga_link_dst_src_write(emu,
764 EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1);
765 snd_emu1010_fpga_link_dst_src_write(emu,
766 EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1);
767 snd_emu1010_fpga_link_dst_src_write(emu,
768 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT2);
769 snd_emu1010_fpga_link_dst_src_write(emu,
770 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT2);
771#endif
772#if 0
773 /* For 192kHz */
774 snd_emu1010_fpga_link_dst_src_write(emu,
775 EMU_DST_ALICE2_EMU32_0, EMU_SRC_HAMOA_ADC_LEFT1);
776 snd_emu1010_fpga_link_dst_src_write(emu,
777 EMU_DST_ALICE2_EMU32_1, EMU_SRC_HAMOA_ADC_RIGHT1);
778 snd_emu1010_fpga_link_dst_src_write(emu,
779 EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2);
780 snd_emu1010_fpga_link_dst_src_write(emu,
781 EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_RIGHT2);
782 snd_emu1010_fpga_link_dst_src_write(emu,
783 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HAMOA_ADC_LEFT3);
784 snd_emu1010_fpga_link_dst_src_write(emu,
785 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HAMOA_ADC_RIGHT3);
786 snd_emu1010_fpga_link_dst_src_write(emu,
787 EMU_DST_ALICE2_EMU32_6, EMU_SRC_HAMOA_ADC_LEFT4);
788 snd_emu1010_fpga_link_dst_src_write(emu,
789 EMU_DST_ALICE2_EMU32_7, EMU_SRC_HAMOA_ADC_RIGHT4);
790#endif
791#if 1
792 /* For 48kHz */
793 snd_emu1010_fpga_link_dst_src_write(emu,
794 EMU_DST_ALICE2_EMU32_0, EMU_SRC_DOCK_MIC_A1);
795 snd_emu1010_fpga_link_dst_src_write(emu,
796 EMU_DST_ALICE2_EMU32_1, EMU_SRC_DOCK_MIC_B1);
797 snd_emu1010_fpga_link_dst_src_write(emu,
798 EMU_DST_ALICE2_EMU32_2, EMU_SRC_HAMOA_ADC_LEFT2);
799 snd_emu1010_fpga_link_dst_src_write(emu,
800 EMU_DST_ALICE2_EMU32_3, EMU_SRC_HAMOA_ADC_LEFT2);
801 snd_emu1010_fpga_link_dst_src_write(emu,
802 EMU_DST_ALICE2_EMU32_4, EMU_SRC_DOCK_ADC1_LEFT1);
803 snd_emu1010_fpga_link_dst_src_write(emu,
804 EMU_DST_ALICE2_EMU32_5, EMU_SRC_DOCK_ADC1_RIGHT1);
805 snd_emu1010_fpga_link_dst_src_write(emu,
806 EMU_DST_ALICE2_EMU32_6, EMU_SRC_DOCK_ADC2_LEFT1);
807 snd_emu1010_fpga_link_dst_src_write(emu,
808 EMU_DST_ALICE2_EMU32_7, EMU_SRC_DOCK_ADC2_RIGHT1);
809#endif
810#if 0
811 /* Original */
812 snd_emu1010_fpga_link_dst_src_write(emu,
813 EMU_DST_ALICE2_EMU32_4, EMU_SRC_HANA_ADAT);
814 snd_emu1010_fpga_link_dst_src_write(emu,
815 EMU_DST_ALICE2_EMU32_5, EMU_SRC_HANA_ADAT + 1);
816 snd_emu1010_fpga_link_dst_src_write(emu,
817 EMU_DST_ALICE2_EMU32_6, EMU_SRC_HANA_ADAT + 2);
818 snd_emu1010_fpga_link_dst_src_write(emu,
819 EMU_DST_ALICE2_EMU32_7, EMU_SRC_HANA_ADAT + 3);
820 snd_emu1010_fpga_link_dst_src_write(emu,
821 EMU_DST_ALICE2_EMU32_8, EMU_SRC_HANA_ADAT + 4);
822 snd_emu1010_fpga_link_dst_src_write(emu,
823 EMU_DST_ALICE2_EMU32_9, EMU_SRC_HANA_ADAT + 5);
824 snd_emu1010_fpga_link_dst_src_write(emu,
825 EMU_DST_ALICE2_EMU32_A, EMU_SRC_HANA_ADAT + 6);
826 snd_emu1010_fpga_link_dst_src_write(emu,
827 EMU_DST_ALICE2_EMU32_B, EMU_SRC_HANA_ADAT + 7);
828 snd_emu1010_fpga_link_dst_src_write(emu,
829 EMU_DST_ALICE2_EMU32_C, EMU_SRC_DOCK_MIC_A1);
830 snd_emu1010_fpga_link_dst_src_write(emu,
831 EMU_DST_ALICE2_EMU32_D, EMU_SRC_DOCK_MIC_B1);
832 snd_emu1010_fpga_link_dst_src_write(emu,
833 EMU_DST_ALICE2_EMU32_E, EMU_SRC_HAMOA_ADC_LEFT2);
834 snd_emu1010_fpga_link_dst_src_write(emu,
835 EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2);
836#endif
837 for (i = 0;i < 0x20; i++ ) {
838 /* AudioDock Elink <- Silence */
839 snd_emu1010_fpga_link_dst_src_write(emu, 0x0100+i, EMU_SRC_SILENCE);
840 }
841 for (i = 0;i < 4; i++) {
842 /* Hana SPDIF Out <- Silence */
843 snd_emu1010_fpga_link_dst_src_write(emu, 0x0200+i, EMU_SRC_SILENCE);
844 }
845 for (i = 0;i < 7; i++) {
846 /* Hamoa DAC <- Silence */
847 snd_emu1010_fpga_link_dst_src_write(emu, 0x0300+i, EMU_SRC_SILENCE);
848 }
849 for (i = 0;i < 7; i++) {
850 /* Hana ADAT Out <- Silence */
851 snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE);
852 }
853 snd_emu1010_fpga_link_dst_src_write(emu,
854 EMU_DST_ALICE_I2S0_LEFT, EMU_SRC_DOCK_ADC1_LEFT1);
855 snd_emu1010_fpga_link_dst_src_write(emu,
856 EMU_DST_ALICE_I2S0_RIGHT, EMU_SRC_DOCK_ADC1_RIGHT1);
857 snd_emu1010_fpga_link_dst_src_write(emu,
858 EMU_DST_ALICE_I2S1_LEFT, EMU_SRC_DOCK_ADC2_LEFT1);
859 snd_emu1010_fpga_link_dst_src_write(emu,
860 EMU_DST_ALICE_I2S1_RIGHT, EMU_SRC_DOCK_ADC2_RIGHT1);
861 snd_emu1010_fpga_link_dst_src_write(emu,
862 EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1);
863 snd_emu1010_fpga_link_dst_src_write(emu,
864 EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1);
865 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01 ); // Unmute all
866
867 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp );
868
869 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave,
870 * Lock Sound Memory Cache, Lock Tank Memory Cache,
871 * Mute all codecs.
872 */
873 outl(0x0000a000, emu->port + HCFG);
874 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave,
875 * Lock Sound Memory Cache, Lock Tank Memory Cache,
876 * Un-Mute all codecs.
877 */
708 outl(0x0000a001, emu->port + HCFG); 878 outl(0x0000a001, emu->port + HCFG);
879
709 /* Initial boot complete. Now patches */ 880 /* Initial boot complete. Now patches */
710 881
711 snd_emu1212m_fpga_read(emu, 0x21, &tmp ); 882 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp );
712 snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); 883 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI, 0x19 ); /* MIDI Route */
713 snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); 884 snd_emu1010_fpga_write(emu, EMU_HANA_UNKNOWN12, 0x0c ); /* Unknown */
714 snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); 885 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI, 0x19 ); /* MIDI Route */
715 snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); 886 snd_emu1010_fpga_write(emu, EMU_HANA_UNKNOWN12, 0x0c ); /* Unknown */
716 snd_emu1212m_fpga_read(emu, 0x0a, &tmp ); 887 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp );
717 snd_emu1212m_fpga_write(emu, 0x0a, 0x10 ); 888 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif (or 0x11 for aes/ebu) */
718 889
719 snd_emu1212m_fpga_read(emu, 0x20, &tmp ); 890 /* Delay to allow Audio Dock to settle */
720 snd_emu1212m_fpga_read(emu, 0x21, &tmp ); 891 msleep(100);
721 892 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */
722 snd_emu1212m_fpga_netlist_write(emu, 0x0300, 0x0312); 893 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); /* OPTIONS: Which cards are attached to the EMU */
723 snd_emu1212m_fpga_netlist_write(emu, 0x0301, 0x0313); 894 /* FIXME: The loading of this should be able to happen any time,
724 snd_emu1212m_fpga_netlist_write(emu, 0x0200, 0x0302); 895 * as the user can plug/unplug it at any time
725 snd_emu1212m_fpga_netlist_write(emu, 0x0201, 0x0303); 896 */
897 if (reg & (EMU_HANA_OPTION_DOCK_ONLINE | EMU_HANA_OPTION_DOCK_OFFLINE) ) {
898 /* Audio Dock attached */
899 /* Return to Audio Dock programming mode */
900 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
901 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK );
902 if ((err = snd_emu1010_load_firmware(emu, dock_filename)) != 0) {
903 return err;
904 }
905 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n");
906 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 );
907 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg );
908 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg);
909 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
910 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg );
911 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg);
912 if (reg != 0x55) {
913 /* FPGA failed to be programmed */
914 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg);
915 return 0;
916 return -ENODEV;
917 }
918 }
919#if 0
920 snd_emu1010_fpga_link_dst_src_write(emu,
921 EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32B + 2); /* ALICE2 bus 0xa2 */
922 snd_emu1010_fpga_link_dst_src_write(emu,
923 EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32B + 3); /* ALICE2 bus 0xa3 */
924 snd_emu1010_fpga_link_dst_src_write(emu,
925 EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 2); /* ALICE2 bus 0xb2 */
926 snd_emu1010_fpga_link_dst_src_write(emu,
927 EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 3); /* ALICE2 bus 0xb3 */
928#endif
929 /* Default outputs */
930 snd_emu1010_fpga_link_dst_src_write(emu,
931 EMU_DST_DOCK_DAC1_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
932 emu->emu1010.output_source[0] = 21;
933 snd_emu1010_fpga_link_dst_src_write(emu,
934 EMU_DST_DOCK_DAC1_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
935 emu->emu1010.output_source[1] = 22;
936 snd_emu1010_fpga_link_dst_src_write(emu,
937 EMU_DST_DOCK_DAC2_LEFT1, EMU_SRC_ALICE_EMU32A + 2);
938 emu->emu1010.output_source[2] = 23;
939 snd_emu1010_fpga_link_dst_src_write(emu,
940 EMU_DST_DOCK_DAC2_RIGHT1, EMU_SRC_ALICE_EMU32A + 3);
941 emu->emu1010.output_source[3] = 24;
942 snd_emu1010_fpga_link_dst_src_write(emu,
943 EMU_DST_DOCK_DAC3_LEFT1, EMU_SRC_ALICE_EMU32A + 4);
944 emu->emu1010.output_source[4] = 25;
945 snd_emu1010_fpga_link_dst_src_write(emu,
946 EMU_DST_DOCK_DAC3_RIGHT1, EMU_SRC_ALICE_EMU32A + 5);
947 emu->emu1010.output_source[5] = 26;
948 snd_emu1010_fpga_link_dst_src_write(emu,
949 EMU_DST_DOCK_DAC4_LEFT1, EMU_SRC_ALICE_EMU32A + 6);
950 emu->emu1010.output_source[6] = 27;
951 snd_emu1010_fpga_link_dst_src_write(emu,
952 EMU_DST_DOCK_DAC4_RIGHT1, EMU_SRC_ALICE_EMU32A + 7);
953 emu->emu1010.output_source[7] = 28;
954 snd_emu1010_fpga_link_dst_src_write(emu,
955 EMU_DST_DOCK_PHONES_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
956 emu->emu1010.output_source[8] = 21;
957 snd_emu1010_fpga_link_dst_src_write(emu,
958 EMU_DST_DOCK_PHONES_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
959 emu->emu1010.output_source[9] = 22;
960 snd_emu1010_fpga_link_dst_src_write(emu,
961 EMU_DST_DOCK_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
962 emu->emu1010.output_source[10] = 21;
963 snd_emu1010_fpga_link_dst_src_write(emu,
964 EMU_DST_DOCK_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
965 emu->emu1010.output_source[11] = 22;
966 snd_emu1010_fpga_link_dst_src_write(emu,
967 EMU_DST_HANA_SPDIF_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
968 emu->emu1010.output_source[12] = 21;
969 snd_emu1010_fpga_link_dst_src_write(emu,
970 EMU_DST_HANA_SPDIF_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
971 emu->emu1010.output_source[13] = 22;
972 snd_emu1010_fpga_link_dst_src_write(emu,
973 EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
974 emu->emu1010.output_source[14] = 21;
975 snd_emu1010_fpga_link_dst_src_write(emu,
976 EMU_DST_HAMOA_DAC_RIGHT1, EMU_SRC_ALICE_EMU32A + 1);
977 emu->emu1010.output_source[15] = 22;
978 snd_emu1010_fpga_link_dst_src_write(emu,
979 EMU_DST_HANA_ADAT, EMU_SRC_ALICE_EMU32A + 0); /* ALICE2 bus 0xa0 */
980 emu->emu1010.output_source[16] = 21;
981 snd_emu1010_fpga_link_dst_src_write(emu,
982 EMU_DST_HANA_ADAT + 1, EMU_SRC_ALICE_EMU32A + 1);
983 emu->emu1010.output_source[17] = 22;
984 snd_emu1010_fpga_link_dst_src_write(emu,
985 EMU_DST_HANA_ADAT + 2, EMU_SRC_ALICE_EMU32A + 2);
986 emu->emu1010.output_source[18] = 23;
987 snd_emu1010_fpga_link_dst_src_write(emu,
988 EMU_DST_HANA_ADAT + 3, EMU_SRC_ALICE_EMU32A + 3);
989 emu->emu1010.output_source[19] = 24;
990 snd_emu1010_fpga_link_dst_src_write(emu,
991 EMU_DST_HANA_ADAT + 4, EMU_SRC_ALICE_EMU32A + 4);
992 emu->emu1010.output_source[20] = 25;
993 snd_emu1010_fpga_link_dst_src_write(emu,
994 EMU_DST_HANA_ADAT + 5, EMU_SRC_ALICE_EMU32A + 5);
995 emu->emu1010.output_source[21] = 26;
996 snd_emu1010_fpga_link_dst_src_write(emu,
997 EMU_DST_HANA_ADAT + 6, EMU_SRC_ALICE_EMU32A + 6);
998 emu->emu1010.output_source[22] = 27;
999 snd_emu1010_fpga_link_dst_src_write(emu,
1000 EMU_DST_HANA_ADAT + 7, EMU_SRC_ALICE_EMU32A + 7);
1001 emu->emu1010.output_source[23] = 28;
1002
1003 /* TEMP: Select SPDIF in/out */
1004 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */
1005
1006 /* TEMP: Select 48kHz SPDIF out */
1007 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */
1008 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */
1009 /* Word Clock source, Internal 48kHz x1 */
1010 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K );
1011 //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X );
1012 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);/* Set LEDs on Audio Dock */
1013 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */
1014 //snd_emu1010_fpga_write(emu, 0x7, 0x0); /* Mute all */
1015 //snd_emu1010_fpga_write(emu, 0x7, 0x1); /* Unmute all */
1016 //snd_emu1010_fpga_write(emu, 0xe, 0x12); /* Set LEDs on Audio Dock */
726 1017
727 return 0; 1018 return 0;
728} 1019}
@@ -747,6 +1038,10 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
747 } 1038 }
748 snd_emu10k1_free_efx(emu); 1039 snd_emu10k1_free_efx(emu);
749 } 1040 }
1041 if (emu->card_capabilities->emu1010) {
1042 /* Disable 48Volt power to Audio Dock */
1043 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 );
1044 }
750 if (emu->memhdr) 1045 if (emu->memhdr)
751 snd_util_memhdr_free(emu->memhdr); 1046 snd_util_memhdr_free(emu->memhdr);
752 if (emu->silent_page.area) 1047 if (emu->silent_page.area)
@@ -865,11 +1160,12 @@ static struct snd_emu_chip_details emu_chip_details[] = {
865 .ac97_chip = 1} , 1160 .ac97_chip = 1} ,
866 /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */ 1161 /* Tested by James@superbug.co.uk 8th July 2005. No sound available yet. */
867 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, 1162 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
868 .driver = "Audigy2", .name = "E-mu 1212m [4001]", 1163 .driver = "Audigy2", .name = "E-mu 1010 [4001]",
869 .id = "EMU1212m", 1164 .id = "EMU1010",
870 .emu10k2_chip = 1, 1165 .emu10k2_chip = 1,
871 .ca0102_chip = 1, 1166 .ca0102_chip = 1,
872 .emu1212m = 1} , 1167 .spk71 = 1,
1168 .emu1010 = 1} ,
873 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1169 /* Tested by James@superbug.co.uk 3rd July 2005 */
874 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, 1170 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102,
875 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", 1171 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]",
@@ -1297,8 +1593,8 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1297 } else if (emu->card_capabilities->ca_cardbus_chip) { 1593 } else if (emu->card_capabilities->ca_cardbus_chip) {
1298 if ((err = snd_emu10k1_cardbus_init(emu)) < 0) 1594 if ((err = snd_emu10k1_cardbus_init(emu)) < 0)
1299 goto error; 1595 goto error;
1300 } else if (emu->card_capabilities->emu1212m) { 1596 } else if (emu->card_capabilities->emu1010) {
1301 if ((err = snd_emu10k1_emu1212m_init(emu)) < 0) { 1597 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) {
1302 snd_emu10k1_free(emu); 1598 snd_emu10k1_free(emu);
1303 return err; 1599 return err;
1304 } 1600 }
@@ -1446,8 +1742,8 @@ void snd_emu10k1_resume_init(struct snd_emu10k1 *emu)
1446 snd_emu10k1_ecard_init(emu); 1742 snd_emu10k1_ecard_init(emu);
1447 else if (emu->card_capabilities->ca_cardbus_chip) 1743 else if (emu->card_capabilities->ca_cardbus_chip)
1448 snd_emu10k1_cardbus_init(emu); 1744 snd_emu10k1_cardbus_init(emu);
1449 else if (emu->card_capabilities->emu1212m) 1745 else if (emu->card_capabilities->emu1010)
1450 snd_emu10k1_emu1212m_init(emu); 1746 snd_emu10k1_emu1010_init(emu);
1451 else 1747 else
1452 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); 1748 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE);
1453 snd_emu10k1_init(emu, emu->enable_ir, 1); 1749 snd_emu10k1_init(emu, emu->enable_ir, 1);