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 | |
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>
-rw-r--r-- | sound/pci/echoaudio/echoaudio.c | 153 | ||||
-rw-r--r-- | sound/pci/echoaudio/echoaudio.h | 2 | ||||
-rw-r--r-- | sound/pci/echoaudio/echoaudio_dsp.c | 145 |
3 files changed, 222 insertions, 78 deletions
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 79dde9592847..2783ce6c236e 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c | |||
@@ -753,6 +753,8 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
753 | 753 | ||
754 | spin_lock(&chip->lock); | 754 | spin_lock(&chip->lock); |
755 | switch (cmd) { | 755 | switch (cmd) { |
756 | case SNDRV_PCM_TRIGGER_RESUME: | ||
757 | DE_ACT(("pcm_trigger resume\n")); | ||
756 | case SNDRV_PCM_TRIGGER_START: | 758 | case SNDRV_PCM_TRIGGER_START: |
757 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 759 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
758 | DE_ACT(("pcm_trigger start\n")); | 760 | DE_ACT(("pcm_trigger start\n")); |
@@ -776,6 +778,8 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
776 | err = start_transport(chip, channelmask, | 778 | err = start_transport(chip, channelmask, |
777 | chip->pipe_cyclic_mask); | 779 | chip->pipe_cyclic_mask); |
778 | break; | 780 | break; |
781 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
782 | DE_ACT(("pcm_trigger suspend\n")); | ||
779 | case SNDRV_PCM_TRIGGER_STOP: | 783 | case SNDRV_PCM_TRIGGER_STOP: |
780 | DE_ACT(("pcm_trigger stop\n")); | 784 | DE_ACT(("pcm_trigger stop\n")); |
781 | for (i = 0; i < DSP_MAXPIPES; i++) { | 785 | for (i = 0; i < DSP_MAXPIPES; i++) { |
@@ -1951,18 +1955,27 @@ static __devinit int snd_echo_create(struct snd_card *card, | |||
1951 | return err; | 1955 | return err; |
1952 | pci_set_master(pci); | 1956 | pci_set_master(pci); |
1953 | 1957 | ||
1954 | /* allocate a chip-specific data */ | 1958 | /* Allocate chip if needed */ |
1955 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1959 | if (!*rchip) { |
1956 | if (!chip) { | 1960 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
1957 | pci_disable_device(pci); | 1961 | if (!chip) { |
1958 | return -ENOMEM; | 1962 | pci_disable_device(pci); |
1963 | return -ENOMEM; | ||
1964 | } | ||
1965 | DE_INIT(("chip=%p\n", chip)); | ||
1966 | spin_lock_init(&chip->lock); | ||
1967 | chip->card = card; | ||
1968 | chip->pci = pci; | ||
1969 | chip->irq = -1; | ||
1970 | atomic_set(&chip->opencount, 0); | ||
1971 | mutex_init(&chip->mode_mutex); | ||
1972 | chip->can_set_rate = 1; | ||
1973 | } else { | ||
1974 | /* If this was called from the resume function, chip is | ||
1975 | * already allocated and it contains current card settings. | ||
1976 | */ | ||
1977 | chip = *rchip; | ||
1959 | } | 1978 | } |
1960 | DE_INIT(("chip=%p\n", chip)); | ||
1961 | |||
1962 | spin_lock_init(&chip->lock); | ||
1963 | chip->card = card; | ||
1964 | chip->pci = pci; | ||
1965 | chip->irq = -1; | ||
1966 | 1979 | ||
1967 | /* PCI resource allocation */ | 1980 | /* PCI resource allocation */ |
1968 | chip->dsp_registers_phys = pci_resource_start(pci, 0); | 1981 | chip->dsp_registers_phys = pci_resource_start(pci, 0); |
@@ -2002,7 +2015,9 @@ static __devinit int snd_echo_create(struct snd_card *card, | |||
2002 | chip->comm_page = (struct comm_page *)chip->commpage_dma_buf.area; | 2015 | chip->comm_page = (struct comm_page *)chip->commpage_dma_buf.area; |
2003 | 2016 | ||
2004 | err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); | 2017 | err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); |
2005 | if (err) { | 2018 | if (err >= 0) |
2019 | err = set_mixer_defaults(chip); | ||
2020 | if (err < 0) { | ||
2006 | DE_INIT(("init_hw err=%d\n", err)); | 2021 | DE_INIT(("init_hw err=%d\n", err)); |
2007 | snd_echo_free(chip); | 2022 | snd_echo_free(chip); |
2008 | return err; | 2023 | return err; |
@@ -2013,9 +2028,6 @@ static __devinit int snd_echo_create(struct snd_card *card, | |||
2013 | snd_echo_free(chip); | 2028 | snd_echo_free(chip); |
2014 | return err; | 2029 | return err; |
2015 | } | 2030 | } |
2016 | atomic_set(&chip->opencount, 0); | ||
2017 | mutex_init(&chip->mode_mutex); | ||
2018 | chip->can_set_rate = 1; | ||
2019 | *rchip = chip; | 2031 | *rchip = chip; |
2020 | /* Init done ! */ | 2032 | /* Init done ! */ |
2021 | return 0; | 2033 | return 0; |
@@ -2048,6 +2060,7 @@ static int __devinit snd_echo_probe(struct pci_dev *pci, | |||
2048 | 2060 | ||
2049 | snd_card_set_dev(card, &pci->dev); | 2061 | snd_card_set_dev(card, &pci->dev); |
2050 | 2062 | ||
2063 | chip = NULL; /* Tells snd_echo_create to allocate chip */ | ||
2051 | if ((err = snd_echo_create(card, pci, &chip)) < 0) { | 2064 | if ((err = snd_echo_create(card, pci, &chip)) < 0) { |
2052 | snd_card_free(card); | 2065 | snd_card_free(card); |
2053 | return err; | 2066 | return err; |
@@ -2187,6 +2200,112 @@ ctl_error: | |||
2187 | 2200 | ||
2188 | 2201 | ||
2189 | 2202 | ||
2203 | #if defined(CONFIG_PM) | ||
2204 | |||
2205 | static int snd_echo_suspend(struct pci_dev *pci, pm_message_t state) | ||
2206 | { | ||
2207 | struct echoaudio *chip = pci_get_drvdata(pci); | ||
2208 | |||
2209 | DE_INIT(("suspend start\n")); | ||
2210 | snd_pcm_suspend_all(chip->analog_pcm); | ||
2211 | snd_pcm_suspend_all(chip->digital_pcm); | ||
2212 | |||
2213 | #ifdef ECHOCARD_HAS_MIDI | ||
2214 | /* This call can sleep */ | ||
2215 | if (chip->midi_out) | ||
2216 | snd_echo_midi_output_trigger(chip->midi_out, 0); | ||
2217 | #endif | ||
2218 | spin_lock_irq(&chip->lock); | ||
2219 | if (wait_handshake(chip)) { | ||
2220 | spin_unlock_irq(&chip->lock); | ||
2221 | return -EIO; | ||
2222 | } | ||
2223 | clear_handshake(chip); | ||
2224 | if (send_vector(chip, DSP_VC_GO_COMATOSE) < 0) { | ||
2225 | spin_unlock_irq(&chip->lock); | ||
2226 | return -EIO; | ||
2227 | } | ||
2228 | spin_unlock_irq(&chip->lock); | ||
2229 | |||
2230 | chip->dsp_code = NULL; | ||
2231 | free_irq(chip->irq, chip); | ||
2232 | chip->irq = -1; | ||
2233 | pci_save_state(pci); | ||
2234 | pci_disable_device(pci); | ||
2235 | |||
2236 | DE_INIT(("suspend done\n")); | ||
2237 | return 0; | ||
2238 | } | ||
2239 | |||
2240 | |||
2241 | |||
2242 | static int snd_echo_resume(struct pci_dev *pci) | ||
2243 | { | ||
2244 | struct echoaudio *chip = pci_get_drvdata(pci); | ||
2245 | struct comm_page *commpage, *commpage_bak; | ||
2246 | u32 pipe_alloc_mask; | ||
2247 | int err; | ||
2248 | |||
2249 | DE_INIT(("resume start\n")); | ||
2250 | pci_restore_state(pci); | ||
2251 | commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL); | ||
2252 | commpage = chip->comm_page; | ||
2253 | memcpy(commpage_bak, commpage, sizeof(struct comm_page)); | ||
2254 | |||
2255 | err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device); | ||
2256 | if (err < 0) { | ||
2257 | kfree(commpage_bak); | ||
2258 | DE_INIT(("resume init_hw err=%d\n", err)); | ||
2259 | snd_echo_free(chip); | ||
2260 | return err; | ||
2261 | } | ||
2262 | DE_INIT(("resume init OK\n")); | ||
2263 | |||
2264 | /* Temporarily set chip->pipe_alloc_mask=0 otherwise | ||
2265 | * restore_dsp_settings() fails. | ||
2266 | */ | ||
2267 | pipe_alloc_mask = chip->pipe_alloc_mask; | ||
2268 | chip->pipe_alloc_mask = 0; | ||
2269 | err = restore_dsp_rettings(chip); | ||
2270 | chip->pipe_alloc_mask = pipe_alloc_mask; | ||
2271 | if (err < 0) { | ||
2272 | kfree(commpage_bak); | ||
2273 | return err; | ||
2274 | } | ||
2275 | DE_INIT(("resume restore OK\n")); | ||
2276 | |||
2277 | memcpy(&commpage->audio_format, &commpage_bak->audio_format, | ||
2278 | sizeof(commpage->audio_format)); | ||
2279 | memcpy(&commpage->sglist_addr, &commpage_bak->sglist_addr, | ||
2280 | sizeof(commpage->sglist_addr)); | ||
2281 | memcpy(&commpage->midi_output, &commpage_bak->midi_output, | ||
2282 | sizeof(commpage->midi_output)); | ||
2283 | kfree(commpage_bak); | ||
2284 | |||
2285 | if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, | ||
2286 | ECHOCARD_NAME, chip)) { | ||
2287 | snd_echo_free(chip); | ||
2288 | snd_printk(KERN_ERR "cannot grab irq\n"); | ||
2289 | return -EBUSY; | ||
2290 | } | ||
2291 | chip->irq = pci->irq; | ||
2292 | DE_INIT(("resume irq=%d\n", chip->irq)); | ||
2293 | |||
2294 | #ifdef ECHOCARD_HAS_MIDI | ||
2295 | if (chip->midi_input_enabled) | ||
2296 | enable_midi_input(chip, TRUE); | ||
2297 | if (chip->midi_out) | ||
2298 | snd_echo_midi_output_trigger(chip->midi_out, 1); | ||
2299 | #endif | ||
2300 | |||
2301 | DE_INIT(("resume done\n")); | ||
2302 | return 0; | ||
2303 | } | ||
2304 | |||
2305 | #endif /* CONFIG_PM */ | ||
2306 | |||
2307 | |||
2308 | |||
2190 | static void __devexit snd_echo_remove(struct pci_dev *pci) | 2309 | static void __devexit snd_echo_remove(struct pci_dev *pci) |
2191 | { | 2310 | { |
2192 | struct echoaudio *chip; | 2311 | struct echoaudio *chip; |
@@ -2209,6 +2328,10 @@ static struct pci_driver driver = { | |||
2209 | .id_table = snd_echo_ids, | 2328 | .id_table = snd_echo_ids, |
2210 | .probe = snd_echo_probe, | 2329 | .probe = snd_echo_probe, |
2211 | .remove = __devexit_p(snd_echo_remove), | 2330 | .remove = __devexit_p(snd_echo_remove), |
2331 | #ifdef CONFIG_PM | ||
2332 | .suspend = snd_echo_suspend, | ||
2333 | .resume = snd_echo_resume, | ||
2334 | #endif /* CONFIG_PM */ | ||
2212 | }; | 2335 | }; |
2213 | 2336 | ||
2214 | 2337 | ||
diff --git a/sound/pci/echoaudio/echoaudio.h b/sound/pci/echoaudio/echoaudio.h index a84c0d15cc50..1df974dcb5f4 100644 --- a/sound/pci/echoaudio/echoaudio.h +++ b/sound/pci/echoaudio/echoaudio.h | |||
@@ -472,6 +472,8 @@ static void free_firmware(const struct firmware *fw_entry); | |||
472 | 472 | ||
473 | #ifdef ECHOCARD_HAS_MIDI | 473 | #ifdef ECHOCARD_HAS_MIDI |
474 | static int enable_midi_input(struct echoaudio *chip, char enable); | 474 | static int enable_midi_input(struct echoaudio *chip, char enable); |
475 | static void snd_echo_midi_output_trigger( | ||
476 | struct snd_rawmidi_substream *substream, int up); | ||
475 | static int midi_service_irq(struct echoaudio *chip); | 477 | static int midi_service_irq(struct echoaudio *chip); |
476 | static int __devinit snd_echo_midi_create(struct snd_card *card, | 478 | static int __devinit snd_echo_midi_create(struct snd_card *card, |
477 | struct echoaudio *chip); | 479 | struct echoaudio *chip); |
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 | ||