diff options
Diffstat (limited to 'sound/pci/echoaudio/echoaudio_dsp.c')
-rw-r--r-- | sound/pci/echoaudio/echoaudio_dsp.c | 157 |
1 files changed, 89 insertions, 68 deletions
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c index 4df51ef5e095..64417a733220 100644 --- a/sound/pci/echoaudio/echoaudio_dsp.c +++ b/sound/pci/echoaudio/echoaudio_dsp.c | |||
@@ -175,15 +175,15 @@ static inline int check_asic_status(struct echoaudio *chip) | |||
175 | #ifdef ECHOCARD_HAS_ASIC | 175 | #ifdef ECHOCARD_HAS_ASIC |
176 | 176 | ||
177 | /* Load ASIC code - done after the DSP is loaded */ | 177 | /* Load ASIC code - done after the DSP is loaded */ |
178 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, | 178 | static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic) |
179 | const struct firmware *asic) | ||
180 | { | 179 | { |
181 | const struct firmware *fw; | 180 | const struct firmware *fw; |
182 | int err; | 181 | int err; |
183 | u32 i, size; | 182 | u32 i, size; |
184 | u8 *code; | 183 | u8 *code; |
185 | 184 | ||
186 | if ((err = get_firmware(&fw, asic, chip)) < 0) { | 185 | err = get_firmware(&fw, chip, asic); |
186 | if (err < 0) { | ||
187 | snd_printk(KERN_WARNING "Firmware not found !\n"); | 187 | snd_printk(KERN_WARNING "Firmware not found !\n"); |
188 | return err; | 188 | return err; |
189 | } | 189 | } |
@@ -245,7 +245,8 @@ static int install_resident_loader(struct echoaudio *chip) | |||
245 | return 0; | 245 | return 0; |
246 | } | 246 | } |
247 | 247 | ||
248 | if ((i = get_firmware(&fw, &card_fw[FW_361_LOADER], chip)) < 0) { | 248 | i = get_firmware(&fw, chip, FW_361_LOADER); |
249 | if (i < 0) { | ||
249 | snd_printk(KERN_WARNING "Firmware not found !\n"); | 250 | snd_printk(KERN_WARNING "Firmware not found !\n"); |
250 | return i; | 251 | return i; |
251 | } | 252 | } |
@@ -485,7 +486,8 @@ static int load_firmware(struct echoaudio *chip) | |||
485 | chip->dsp_code = NULL; | 486 | chip->dsp_code = NULL; |
486 | } | 487 | } |
487 | 488 | ||
488 | if ((err = get_firmware(&fw, chip->dsp_code_to_load, chip)) < 0) | 489 | err = get_firmware(&fw, chip, chip->dsp_code_to_load); |
490 | if (err < 0) | ||
489 | return err; | 491 | return err; |
490 | err = load_dsp(chip, (u16 *)fw->data); | 492 | err = load_dsp(chip, (u16 *)fw->data); |
491 | free_firmware(fw); | 493 | free_firmware(fw); |
@@ -495,9 +497,6 @@ static int load_firmware(struct echoaudio *chip) | |||
495 | if ((box_type = load_asic(chip)) < 0) | 497 | if ((box_type = load_asic(chip)) < 0) |
496 | return box_type; /* error */ | 498 | return box_type; /* error */ |
497 | 499 | ||
498 | if ((err = restore_dsp_rettings(chip)) < 0) | ||
499 | return err; | ||
500 | |||
501 | return box_type; | 500 | return box_type; |
502 | } | 501 | } |
503 | 502 | ||
@@ -657,51 +656,106 @@ static void get_audio_meters(struct echoaudio *chip, long *meters) | |||
657 | 656 | ||
658 | static int restore_dsp_rettings(struct echoaudio *chip) | 657 | static int restore_dsp_rettings(struct echoaudio *chip) |
659 | { | 658 | { |
660 | int err; | 659 | int i, o, err; |
661 | DE_INIT(("restore_dsp_settings\n")); | 660 | DE_INIT(("restore_dsp_settings\n")); |
662 | 661 | ||
663 | if ((err = check_asic_status(chip)) < 0) | 662 | if ((err = check_asic_status(chip)) < 0) |
664 | return err; | 663 | return err; |
665 | 664 | ||
666 | /* @ Gina20/Darla20 only. Should be harmless for other cards. */ | 665 | /* Gina20/Darla20 only. Should be harmless for other cards. */ |
667 | chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; | 666 | chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; |
668 | chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; | 667 | chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; |
669 | chip->comm_page->handshake = 0xffffffff; | 668 | chip->comm_page->handshake = 0xffffffff; |
670 | 669 | ||
671 | if ((err = set_sample_rate(chip, chip->sample_rate)) < 0) | 670 | /* Restore output busses */ |
671 | for (i = 0; i < num_busses_out(chip); i++) { | ||
672 | err = set_output_gain(chip, i, chip->output_gain[i]); | ||
673 | if (err < 0) | ||
674 | return err; | ||
675 | } | ||
676 | |||
677 | #ifdef ECHOCARD_HAS_VMIXER | ||
678 | for (i = 0; i < num_pipes_out(chip); i++) | ||
679 | for (o = 0; o < num_busses_out(chip); o++) { | ||
680 | err = set_vmixer_gain(chip, o, i, | ||
681 | chip->vmixer_gain[o][i]); | ||
682 | if (err < 0) | ||
683 | return err; | ||
684 | } | ||
685 | if (update_vmixer_level(chip) < 0) | ||
686 | return -EIO; | ||
687 | #endif /* ECHOCARD_HAS_VMIXER */ | ||
688 | |||
689 | #ifdef ECHOCARD_HAS_MONITOR | ||
690 | for (o = 0; o < num_busses_out(chip); o++) | ||
691 | for (i = 0; i < num_busses_in(chip); i++) { | ||
692 | err = set_monitor_gain(chip, o, i, | ||
693 | chip->monitor_gain[o][i]); | ||
694 | if (err < 0) | ||
695 | return err; | ||
696 | } | ||
697 | #endif /* ECHOCARD_HAS_MONITOR */ | ||
698 | |||
699 | #ifdef ECHOCARD_HAS_INPUT_GAIN | ||
700 | for (i = 0; i < num_busses_in(chip); i++) { | ||
701 | err = set_input_gain(chip, i, chip->input_gain[i]); | ||
702 | if (err < 0) | ||
703 | return err; | ||
704 | } | ||
705 | #endif /* ECHOCARD_HAS_INPUT_GAIN */ | ||
706 | |||
707 | err = update_output_line_level(chip); | ||
708 | if (err < 0) | ||
672 | return err; | 709 | return err; |
673 | 710 | ||
674 | if (chip->meters_enabled) | 711 | err = update_input_line_level(chip); |
675 | if (send_vector(chip, DSP_VC_METERS_ON) < 0) | 712 | if (err < 0) |
676 | return -EIO; | 713 | return err; |
677 | 714 | ||
678 | #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK | 715 | err = set_sample_rate(chip, chip->sample_rate); |
679 | if (set_input_clock(chip, chip->input_clock) < 0) | 716 | if (err < 0) |
717 | return err; | ||
718 | |||
719 | if (chip->meters_enabled) { | ||
720 | err = send_vector(chip, DSP_VC_METERS_ON); | ||
721 | if (err < 0) | ||
722 | return err; | ||
723 | } | ||
724 | |||
725 | #ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH | ||
726 | if (set_digital_mode(chip, chip->digital_mode) < 0) | ||
680 | return -EIO; | 727 | return -EIO; |
681 | #endif | 728 | #endif |
682 | 729 | ||
683 | #ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH | 730 | #ifdef ECHOCARD_HAS_DIGITAL_IO |
684 | if (set_output_clock(chip, chip->output_clock) < 0) | 731 | if (set_professional_spdif(chip, chip->professional_spdif) < 0) |
685 | return -EIO; | 732 | return -EIO; |
686 | #endif | 733 | #endif |
687 | 734 | ||
688 | if (update_output_line_level(chip) < 0) | 735 | #ifdef ECHOCARD_HAS_PHANTOM_POWER |
736 | if (set_phantom_power(chip, chip->phantom_power) < 0) | ||
689 | return -EIO; | 737 | return -EIO; |
738 | #endif | ||
690 | 739 | ||
691 | if (update_input_line_level(chip) < 0) | 740 | #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK |
741 | /* set_input_clock() also restores automute setting */ | ||
742 | if (set_input_clock(chip, chip->input_clock) < 0) | ||
692 | return -EIO; | 743 | return -EIO; |
744 | #endif | ||
693 | 745 | ||
694 | #ifdef ECHOCARD_HAS_VMIXER | 746 | #ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH |
695 | if (update_vmixer_level(chip) < 0) | 747 | if (set_output_clock(chip, chip->output_clock) < 0) |
696 | return -EIO; | 748 | return -EIO; |
697 | #endif | 749 | #endif |
698 | 750 | ||
699 | if (wait_handshake(chip) < 0) | 751 | if (wait_handshake(chip) < 0) |
700 | return -EIO; | 752 | return -EIO; |
701 | clear_handshake(chip); | 753 | clear_handshake(chip); |
754 | if (send_vector(chip, DSP_VC_UPDATE_FLAGS) < 0) | ||
755 | return -EIO; | ||
702 | 756 | ||
703 | DE_INIT(("restore_dsp_rettings done\n")); | 757 | DE_INIT(("restore_dsp_rettings done\n")); |
704 | return send_vector(chip, DSP_VC_UPDATE_FLAGS); | 758 | return 0; |
705 | } | 759 | } |
706 | 760 | ||
707 | 761 | ||
@@ -918,9 +972,6 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
918 | chip->card_name = ECHOCARD_NAME; | 972 | chip->card_name = ECHOCARD_NAME; |
919 | chip->bad_board = TRUE; /* Set TRUE until DSP loaded */ | 973 | chip->bad_board = TRUE; /* Set TRUE until DSP loaded */ |
920 | chip->dsp_code = NULL; /* Current DSP code not loaded */ | 974 | chip->dsp_code = NULL; /* Current DSP code not loaded */ |
921 | chip->digital_mode = DIGITAL_MODE_NONE; | ||
922 | chip->input_clock = ECHO_CLOCK_INTERNAL; | ||
923 | chip->output_clock = ECHO_CLOCK_WORD; | ||
924 | chip->asic_loaded = FALSE; | 975 | chip->asic_loaded = FALSE; |
925 | memset(chip->comm_page, 0, sizeof(struct comm_page)); | 976 | memset(chip->comm_page, 0, sizeof(struct comm_page)); |
926 | 977 | ||
@@ -931,7 +982,6 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
931 | chip->comm_page->midi_out_free_count = | 982 | chip->comm_page->midi_out_free_count = |
932 | cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE); | 983 | cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE); |
933 | chip->comm_page->sample_rate = cpu_to_le32(44100); | 984 | chip->comm_page->sample_rate = cpu_to_le32(44100); |
934 | chip->sample_rate = 44100; | ||
935 | 985 | ||
936 | /* Set line levels so we don't blast any inputs on startup */ | 986 | /* Set line levels so we don't blast any inputs on startup */ |
937 | memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); | 987 | memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); |
@@ -942,50 +992,21 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
942 | 992 | ||
943 | 993 | ||
944 | 994 | ||
945 | /* This function initializes the several volume controls for busses and pipes. | 995 | /* This function initializes the chip structure with default values, ie. all |
946 | This MUST be called after the DSP is up and running ! */ | 996 | * muted and internal clock source. Then it copies the settings to the DSP. |
997 | * This MUST be called after the DSP is up and running ! | ||
998 | */ | ||
947 | static int init_line_levels(struct echoaudio *chip) | 999 | static int init_line_levels(struct echoaudio *chip) |
948 | { | 1000 | { |
949 | int st, i, o; | ||
950 | |||
951 | DE_INIT(("init_line_levels\n")); | 1001 | DE_INIT(("init_line_levels\n")); |
952 | 1002 | memset(chip->output_gain, ECHOGAIN_MUTED, sizeof(chip->output_gain)); | |
953 | /* Mute output busses */ | 1003 | memset(chip->input_gain, ECHOGAIN_MUTED, sizeof(chip->input_gain)); |
954 | for (i = 0; i < num_busses_out(chip); i++) | 1004 | memset(chip->monitor_gain, ECHOGAIN_MUTED, sizeof(chip->monitor_gain)); |
955 | if ((st = set_output_gain(chip, i, ECHOGAIN_MUTED))) | 1005 | memset(chip->vmixer_gain, ECHOGAIN_MUTED, sizeof(chip->vmixer_gain)); |
956 | return st; | 1006 | chip->input_clock = ECHO_CLOCK_INTERNAL; |
957 | if ((st = update_output_line_level(chip))) | 1007 | chip->output_clock = ECHO_CLOCK_WORD; |
958 | return st; | 1008 | chip->sample_rate = 44100; |
959 | 1009 | return restore_dsp_rettings(chip); | |
960 | #ifdef ECHOCARD_HAS_VMIXER | ||
961 | /* Mute the Vmixer */ | ||
962 | for (i = 0; i < num_pipes_out(chip); i++) | ||
963 | for (o = 0; o < num_busses_out(chip); o++) | ||
964 | if ((st = set_vmixer_gain(chip, o, i, ECHOGAIN_MUTED))) | ||
965 | return st; | ||
966 | if ((st = update_vmixer_level(chip))) | ||
967 | return st; | ||
968 | #endif /* ECHOCARD_HAS_VMIXER */ | ||
969 | |||
970 | #ifdef ECHOCARD_HAS_MONITOR | ||
971 | /* Mute the monitor mixer */ | ||
972 | for (o = 0; o < num_busses_out(chip); o++) | ||
973 | for (i = 0; i < num_busses_in(chip); i++) | ||
974 | if ((st = set_monitor_gain(chip, o, i, ECHOGAIN_MUTED))) | ||
975 | return st; | ||
976 | if ((st = update_output_line_level(chip))) | ||
977 | return st; | ||
978 | #endif /* ECHOCARD_HAS_MONITOR */ | ||
979 | |||
980 | #ifdef ECHOCARD_HAS_INPUT_GAIN | ||
981 | for (i = 0; i < num_busses_in(chip); i++) | ||
982 | if ((st = set_input_gain(chip, i, ECHOGAIN_MUTED))) | ||
983 | return st; | ||
984 | if ((st = update_input_line_level(chip))) | ||
985 | return st; | ||
986 | #endif /* ECHOCARD_HAS_INPUT_GAIN */ | ||
987 | |||
988 | return 0; | ||
989 | } | 1010 | } |
990 | 1011 | ||
991 | 1012 | ||