diff options
author | Giuliano Pochini <pochini@shiny.it> | 2010-02-14 12:16:10 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-02-15 04:40:15 -0500 |
commit | 47b5d028fdce8f809bf22852ac900338fb90e8aa (patch) | |
tree | a9afb96040863610ca4348d95d120cd430341be0 /sound/pci/echoaudio/echoaudio_dsp.c | |
parent | ad3499f4668f684ef6e5d0222ae14d5e4ade1fdd (diff) |
ALSA: Echoaudio - Add suspend support #2
This patch adds rearranges parts of the initialization code and adds
suspend and resume callbacks.
This patch adds suspend and resume callbacks.
It also rearranges parts of the initialization code so it can be
used in both the first initialization (when the module is loaded we
also have to load default settings) and the resume callback (where
we have to restore the previous settings).
Signed-off-by: Giuliano Pochini <pochini@shiny.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/echoaudio/echoaudio_dsp.c')
-rw-r--r-- | sound/pci/echoaudio/echoaudio_dsp.c | 145 |
1 files changed, 82 insertions, 63 deletions
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c index 031ef7e9da91..64417a733220 100644 --- a/sound/pci/echoaudio/echoaudio_dsp.c +++ b/sound/pci/echoaudio/echoaudio_dsp.c | |||
@@ -497,9 +497,6 @@ static int load_firmware(struct echoaudio *chip) | |||
497 | if ((box_type = load_asic(chip)) < 0) | 497 | if ((box_type = load_asic(chip)) < 0) |
498 | return box_type; /* error */ | 498 | return box_type; /* error */ |
499 | 499 | ||
500 | if ((err = restore_dsp_rettings(chip)) < 0) | ||
501 | return err; | ||
502 | |||
503 | return box_type; | 500 | return box_type; |
504 | } | 501 | } |
505 | 502 | ||
@@ -659,51 +656,106 @@ static void get_audio_meters(struct echoaudio *chip, long *meters) | |||
659 | 656 | ||
660 | static int restore_dsp_rettings(struct echoaudio *chip) | 657 | static int restore_dsp_rettings(struct echoaudio *chip) |
661 | { | 658 | { |
662 | int err; | 659 | int i, o, err; |
663 | DE_INIT(("restore_dsp_settings\n")); | 660 | DE_INIT(("restore_dsp_settings\n")); |
664 | 661 | ||
665 | if ((err = check_asic_status(chip)) < 0) | 662 | if ((err = check_asic_status(chip)) < 0) |
666 | return err; | 663 | return err; |
667 | 664 | ||
668 | /* @ Gina20/Darla20 only. Should be harmless for other cards. */ | 665 | /* Gina20/Darla20 only. Should be harmless for other cards. */ |
669 | chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; | 666 | chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; |
670 | chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; | 667 | chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; |
671 | chip->comm_page->handshake = 0xffffffff; | 668 | chip->comm_page->handshake = 0xffffffff; |
672 | 669 | ||
673 | 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) | ||
674 | return err; | 709 | return err; |
675 | 710 | ||
676 | if (chip->meters_enabled) | 711 | err = update_input_line_level(chip); |
677 | if (send_vector(chip, DSP_VC_METERS_ON) < 0) | 712 | if (err < 0) |
678 | return -EIO; | 713 | return err; |
679 | 714 | ||
680 | #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK | 715 | err = set_sample_rate(chip, chip->sample_rate); |
681 | 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) | ||
682 | return -EIO; | 727 | return -EIO; |
683 | #endif | 728 | #endif |
684 | 729 | ||
685 | #ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH | 730 | #ifdef ECHOCARD_HAS_DIGITAL_IO |
686 | if (set_output_clock(chip, chip->output_clock) < 0) | 731 | if (set_professional_spdif(chip, chip->professional_spdif) < 0) |
687 | return -EIO; | 732 | return -EIO; |
688 | #endif | 733 | #endif |
689 | 734 | ||
690 | if (update_output_line_level(chip) < 0) | 735 | #ifdef ECHOCARD_HAS_PHANTOM_POWER |
736 | if (set_phantom_power(chip, chip->phantom_power) < 0) | ||
691 | return -EIO; | 737 | return -EIO; |
738 | #endif | ||
692 | 739 | ||
693 | 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) | ||
694 | return -EIO; | 743 | return -EIO; |
744 | #endif | ||
695 | 745 | ||
696 | #ifdef ECHOCARD_HAS_VMIXER | 746 | #ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH |
697 | if (update_vmixer_level(chip) < 0) | 747 | if (set_output_clock(chip, chip->output_clock) < 0) |
698 | return -EIO; | 748 | return -EIO; |
699 | #endif | 749 | #endif |
700 | 750 | ||
701 | if (wait_handshake(chip) < 0) | 751 | if (wait_handshake(chip) < 0) |
702 | return -EIO; | 752 | return -EIO; |
703 | clear_handshake(chip); | 753 | clear_handshake(chip); |
754 | if (send_vector(chip, DSP_VC_UPDATE_FLAGS) < 0) | ||
755 | return -EIO; | ||
704 | 756 | ||
705 | DE_INIT(("restore_dsp_rettings done\n")); | 757 | DE_INIT(("restore_dsp_rettings done\n")); |
706 | return send_vector(chip, DSP_VC_UPDATE_FLAGS); | 758 | return 0; |
707 | } | 759 | } |
708 | 760 | ||
709 | 761 | ||
@@ -920,9 +972,6 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
920 | chip->card_name = ECHOCARD_NAME; | 972 | chip->card_name = ECHOCARD_NAME; |
921 | chip->bad_board = TRUE; /* Set TRUE until DSP loaded */ | 973 | chip->bad_board = TRUE; /* Set TRUE until DSP loaded */ |
922 | chip->dsp_code = NULL; /* Current DSP code not loaded */ | 974 | chip->dsp_code = NULL; /* Current DSP code not loaded */ |
923 | chip->digital_mode = DIGITAL_MODE_NONE; | ||
924 | chip->input_clock = ECHO_CLOCK_INTERNAL; | ||
925 | chip->output_clock = ECHO_CLOCK_WORD; | ||
926 | chip->asic_loaded = FALSE; | 975 | chip->asic_loaded = FALSE; |
927 | memset(chip->comm_page, 0, sizeof(struct comm_page)); | 976 | memset(chip->comm_page, 0, sizeof(struct comm_page)); |
928 | 977 | ||
@@ -933,7 +982,6 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
933 | chip->comm_page->midi_out_free_count = | 982 | chip->comm_page->midi_out_free_count = |
934 | cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE); | 983 | cpu_to_le32(DSP_MIDI_OUT_FIFO_SIZE); |
935 | chip->comm_page->sample_rate = cpu_to_le32(44100); | 984 | chip->comm_page->sample_rate = cpu_to_le32(44100); |
936 | chip->sample_rate = 44100; | ||
937 | 985 | ||
938 | /* 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 */ |
939 | memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); | 987 | memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); |
@@ -944,50 +992,21 @@ static int init_dsp_comm_page(struct echoaudio *chip) | |||
944 | 992 | ||
945 | 993 | ||
946 | 994 | ||
947 | /* This function initializes the several volume controls for busses and pipes. | 995 | /* This function initializes the chip structure with default values, ie. all |
948 | 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 | */ | ||
949 | static int init_line_levels(struct echoaudio *chip) | 999 | static int init_line_levels(struct echoaudio *chip) |
950 | { | 1000 | { |
951 | int st, i, o; | ||
952 | |||
953 | DE_INIT(("init_line_levels\n")); | 1001 | DE_INIT(("init_line_levels\n")); |
954 | 1002 | memset(chip->output_gain, ECHOGAIN_MUTED, sizeof(chip->output_gain)); | |
955 | /* Mute output busses */ | 1003 | memset(chip->input_gain, ECHOGAIN_MUTED, sizeof(chip->input_gain)); |
956 | for (i = 0; i < num_busses_out(chip); i++) | 1004 | memset(chip->monitor_gain, ECHOGAIN_MUTED, sizeof(chip->monitor_gain)); |
957 | if ((st = set_output_gain(chip, i, ECHOGAIN_MUTED))) | 1005 | memset(chip->vmixer_gain, ECHOGAIN_MUTED, sizeof(chip->vmixer_gain)); |
958 | return st; | 1006 | chip->input_clock = ECHO_CLOCK_INTERNAL; |
959 | if ((st = update_output_line_level(chip))) | 1007 | chip->output_clock = ECHO_CLOCK_WORD; |
960 | return st; | 1008 | chip->sample_rate = 44100; |
961 | 1009 | return restore_dsp_rettings(chip); | |
962 | #ifdef ECHOCARD_HAS_VMIXER | ||
963 | /* Mute the Vmixer */ | ||
964 | for (i = 0; i < num_pipes_out(chip); i++) | ||
965 | for (o = 0; o < num_busses_out(chip); o++) | ||
966 | if ((st = set_vmixer_gain(chip, o, i, ECHOGAIN_MUTED))) | ||
967 | return st; | ||
968 | if ((st = update_vmixer_level(chip))) | ||
969 | return st; | ||
970 | #endif /* ECHOCARD_HAS_VMIXER */ | ||
971 | |||
972 | #ifdef ECHOCARD_HAS_MONITOR | ||
973 | /* Mute the monitor mixer */ | ||
974 | for (o = 0; o < num_busses_out(chip); o++) | ||
975 | for (i = 0; i < num_busses_in(chip); i++) | ||
976 | if ((st = set_monitor_gain(chip, o, i, ECHOGAIN_MUTED))) | ||
977 | return st; | ||
978 | if ((st = update_output_line_level(chip))) | ||
979 | return st; | ||
980 | #endif /* ECHOCARD_HAS_MONITOR */ | ||
981 | |||
982 | #ifdef ECHOCARD_HAS_INPUT_GAIN | ||
983 | for (i = 0; i < num_busses_in(chip); i++) | ||
984 | if ((st = set_input_gain(chip, i, ECHOGAIN_MUTED))) | ||
985 | return st; | ||
986 | if ((st = update_input_line_level(chip))) | ||
987 | return st; | ||
988 | #endif /* ECHOCARD_HAS_INPUT_GAIN */ | ||
989 | |||
990 | return 0; | ||
991 | } | 1010 | } |
992 | 1011 | ||
993 | 1012 | ||