diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 13:13:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 13:13:38 -0400 |
commit | fc8a327db6c46de783b1a4276d846841b9abc24c (patch) | |
tree | bee512c142cccea93511debd98ef954581693727 /sound/pci/emu10k1/emu10k1_main.c | |
parent | 92d15c2ccbb3e31a3fc71ad28fdb55e1319383c0 (diff) | |
parent | 24837e6f249a2c83667552e6871c1543b4a6b934 (diff) |
Merge branch 'linus' of master.kernel.org:/pub/scm/linux/kernel/git/perex/alsa
* 'linus' of master.kernel.org:/pub/scm/linux/kernel/git/perex/alsa: (264 commits)
[ALSA] version 1.0.15
[ALSA] Fix thinko in cs4231 mce down check
[ALSA] sun-cs4231: improved waiting after MCE down
[ALSA] sun-cs4231: use cs4231-regs.h
[ALSA] This simplifies and fixes waiting loops of the mce_down()
[ALSA] This patch adds support for a wavetable chip on
[ALSA] This patch removes open_mutex from the ad1848-lib as
[ALSA] fix bootup crash in snd_gus_interrupt()
[ALSA] hda-codec - Fix SKU ID function for realtek codecs
[ALSA] Support ASUS P701 eeepc [0x1043 0x82a1] support
[ALSA] hda-codec - Add array terminator for dmic in STAC codec
[ALSA] hdsp - Fix zero division
[ALSA] usb-audio - Fix double comment
[ALSA] hda-codec - Fix STAC922x volume knob control
[ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz
[ALSA] hda-codec - Fix for Fujitsu Lifebook C1410
[ALSA] mpu-401: remove MPU401_INFO_UART_ONLY flag
[ALSA] mpu-401: do not require an ACK byte for the ENTER_UART command
[ALSA] via82xx - Add DXS quirk for Shuttle AK31v2
[ALSA] hda-codec - Fix input_mux numbers for vaio stac92xx
...
Diffstat (limited to 'sound/pci/emu10k1/emu10k1_main.c')
-rw-r--r-- | sound/pci/emu10k1/emu10k1_main.c | 130 |
1 files changed, 82 insertions, 48 deletions
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 404ae1be0a4b..97c41d72a255 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> | 2 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
3 | * Creative Labs, Inc. | 3 | * Creative Labs, Inc. |
4 | * Routines for control of EMU10K1 chips | 4 | * Routines for control of EMU10K1 chips |
5 | * | 5 | * |
@@ -31,6 +31,8 @@ | |||
31 | * | 31 | * |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/sched.h> | ||
35 | #include <linux/kthread.h> | ||
34 | #include <sound/driver.h> | 36 | #include <sound/driver.h> |
35 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
36 | #include <linux/init.h> | 38 | #include <linux/init.h> |
@@ -702,6 +704,65 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file | |||
702 | return 0; | 704 | return 0; |
703 | } | 705 | } |
704 | 706 | ||
707 | int emu1010_firmware_thread(void *data) { | ||
708 | struct snd_emu10k1 * emu = data; | ||
709 | int tmp,tmp2; | ||
710 | int reg; | ||
711 | int err; | ||
712 | |||
713 | for (;;) { | ||
714 | /* Delay to allow Audio Dock to settle */ | ||
715 | msleep(1000); | ||
716 | if (kthread_should_stop()) | ||
717 | break; | ||
718 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */ | ||
719 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); /* OPTIONS: Which cards are attached to the EMU */ | ||
720 | if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { | ||
721 | /* Audio Dock attached */ | ||
722 | /* Return to Audio Dock programming mode */ | ||
723 | snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); | ||
724 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); | ||
725 | if (emu->card_capabilities->emu1010 == 1) { | ||
726 | if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) { | ||
727 | return err; | ||
728 | } | ||
729 | } else if (emu->card_capabilities->emu1010 == 2) { | ||
730 | if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { | ||
731 | return err; | ||
732 | } | ||
733 | } else if (emu->card_capabilities->emu1010 == 3) { | ||
734 | if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { | ||
735 | return err; | ||
736 | } | ||
737 | } | ||
738 | |||
739 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); | ||
740 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ® ); | ||
741 | snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); | ||
742 | /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ | ||
743 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); | ||
744 | snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); | ||
745 | if ((reg & 0x1f) != 0x15) { | ||
746 | /* FPGA failed to be programmed */ | ||
747 | snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); | ||
748 | return 0; | ||
749 | return -ENODEV; | ||
750 | } | ||
751 | snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); | ||
752 | snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp ); | ||
753 | snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2 ); | ||
754 | snd_printk("Audio Dock ver:%d.%d\n",tmp ,tmp2); | ||
755 | /* Sync clocking between 1010 and Dock */ | ||
756 | /* Allow DLL to settle */ | ||
757 | msleep(10); | ||
758 | /* Unmute all. Default is muted after a firmware load */ | ||
759 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); | ||
760 | break; | ||
761 | } | ||
762 | } | ||
763 | return 0; | ||
764 | } | ||
765 | |||
705 | /* | 766 | /* |
706 | * EMU-1010 - details found out from this driver, official MS Win drivers, | 767 | * EMU-1010 - details found out from this driver, official MS Win drivers, |
707 | * testing the card: | 768 | * testing the card: |
@@ -817,8 +878,16 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) | |||
817 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); | 878 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); |
818 | snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); | 879 | snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); |
819 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); | 880 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); |
820 | /* ADAT input. */ | 881 | /* Optical -> ADAT I/O */ |
821 | snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x01 ); | 882 | /* 0 : SPDIF |
883 | * 1 : ADAT | ||
884 | */ | ||
885 | emu->emu1010.optical_in = 1; /* IN_ADAT */ | ||
886 | emu->emu1010.optical_out = 1; /* IN_ADAT */ | ||
887 | tmp = 0; | ||
888 | tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) | | ||
889 | (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0); | ||
890 | snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp ); | ||
822 | snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp ); | 891 | snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp ); |
823 | /* Set no attenuation on Audio Dock pads. */ | 892 | /* Set no attenuation on Audio Dock pads. */ |
824 | snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 ); | 893 | snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 ); |
@@ -1004,49 +1073,12 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) | |||
1004 | snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); | 1073 | snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); |
1005 | snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif (or 0x11 for aes/ebu) */ | 1074 | snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif (or 0x11 for aes/ebu) */ |
1006 | 1075 | ||
1007 | /* Delay to allow Audio Dock to settle */ | 1076 | /* Start Micro/Audio Dock firmware loader thread */ |
1008 | msleep(100); | 1077 | emu->emu1010.firmware_thread = kthread_create(&emu1010_firmware_thread, |
1009 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */ | 1078 | emu, |
1010 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ® ); /* OPTIONS: Which cards are attached to the EMU */ | 1079 | "emu1010_firmware"); |
1011 | /* FIXME: The loading of this should be able to happen any time, | 1080 | wake_up_process(emu->emu1010.firmware_thread); |
1012 | * as the user can plug/unplug it at any time | ||
1013 | */ | ||
1014 | if (reg & (EMU_HANA_OPTION_DOCK_ONLINE | EMU_HANA_OPTION_DOCK_OFFLINE) ) { | ||
1015 | /* Audio Dock attached */ | ||
1016 | /* Return to Audio Dock programming mode */ | ||
1017 | snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); | ||
1018 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); | ||
1019 | if (emu->card_capabilities->emu1010 == 1) { | ||
1020 | if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) { | ||
1021 | return err; | ||
1022 | } | ||
1023 | } else if (emu->card_capabilities->emu1010 == 2) { | ||
1024 | if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { | ||
1025 | return err; | ||
1026 | } | ||
1027 | } else if (emu->card_capabilities->emu1010 == 3) { | ||
1028 | if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { | ||
1029 | return err; | ||
1030 | } | ||
1031 | } | ||
1032 | 1081 | ||
1033 | snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); | ||
1034 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ® ); | ||
1035 | snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); | ||
1036 | /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ | ||
1037 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ® ); | ||
1038 | snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); | ||
1039 | if ((reg & 0x3f) != 0x15) { | ||
1040 | /* FPGA failed to be programmed */ | ||
1041 | snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); | ||
1042 | return 0; | ||
1043 | return -ENODEV; | ||
1044 | } | ||
1045 | snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); | ||
1046 | snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp ); | ||
1047 | snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2 ); | ||
1048 | snd_printk("Audio Dock ver:%d.%d\n",tmp ,tmp2); | ||
1049 | } | ||
1050 | #if 0 | 1082 | #if 0 |
1051 | snd_emu1010_fpga_link_dst_src_write(emu, | 1083 | snd_emu1010_fpga_link_dst_src_write(emu, |
1052 | EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32B + 2); /* ALICE2 bus 0xa2 */ | 1084 | EMU_DST_HAMOA_DAC_LEFT1, EMU_SRC_ALICE_EMU32B + 2); /* ALICE2 bus 0xa2 */ |
@@ -1132,7 +1164,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) | |||
1132 | emu->emu1010.output_source[23] = 28; | 1164 | emu->emu1010.output_source[23] = 28; |
1133 | 1165 | ||
1134 | /* TEMP: Select SPDIF in/out */ | 1166 | /* TEMP: Select SPDIF in/out */ |
1135 | snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */ | 1167 | //snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */ |
1136 | 1168 | ||
1137 | /* TEMP: Select 48kHz SPDIF out */ | 1169 | /* TEMP: Select 48kHz SPDIF out */ |
1138 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */ | 1170 | snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */ |
@@ -1173,6 +1205,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu) | |||
1173 | if (emu->card_capabilities->emu1010) { | 1205 | if (emu->card_capabilities->emu1010) { |
1174 | /* Disable 48Volt power to Audio Dock */ | 1206 | /* Disable 48Volt power to Audio Dock */ |
1175 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); | 1207 | snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); |
1208 | kthread_stop(emu->emu1010.firmware_thread); | ||
1176 | } | 1209 | } |
1177 | if (emu->memhdr) | 1210 | if (emu->memhdr) |
1178 | snd_util_memhdr_free(emu->memhdr); | 1211 | snd_util_memhdr_free(emu->memhdr); |
@@ -1722,8 +1755,9 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1722 | goto error; | 1755 | goto error; |
1723 | } | 1756 | } |
1724 | 1757 | ||
1725 | emu->page_ptr_table = (void **)vmalloc(emu->max_cache_pages * sizeof(void*)); | 1758 | emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *)); |
1726 | emu->page_addr_table = (unsigned long*)vmalloc(emu->max_cache_pages * sizeof(unsigned long)); | 1759 | emu->page_addr_table = vmalloc(emu->max_cache_pages * |
1760 | sizeof(unsigned long)); | ||
1727 | if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { | 1761 | if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { |
1728 | err = -ENOMEM; | 1762 | err = -ENOMEM; |
1729 | goto error; | 1763 | goto error; |