aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/echoaudio/echo3g_dsp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/echoaudio/echo3g_dsp.c')
-rw-r--r--sound/pci/echoaudio/echo3g_dsp.c131
1 files changed, 131 insertions, 0 deletions
diff --git a/sound/pci/echoaudio/echo3g_dsp.c b/sound/pci/echoaudio/echo3g_dsp.c
new file mode 100644
index 000000000000..d26a1d1f3ed1
--- /dev/null
+++ b/sound/pci/echoaudio/echo3g_dsp.c
@@ -0,0 +1,131 @@
1/****************************************************************************
2
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
4 All rights reserved
5 www.echoaudio.com
6
7 This file is part of Echo Digital Audio's generic driver library.
8
9 Echo Digital Audio's generic driver library is free software;
10 you can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software
12 Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
23
24 *************************************************************************
25
26 Translation from C++ and adaptation for use in ALSA-Driver
27 were made by Giuliano Pochini <pochini@shiny.it>
28
29****************************************************************************/
30
31static int load_asic(struct echoaudio *chip);
32static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode);
33static int set_digital_mode(struct echoaudio *chip, u8 mode);
34static int check_asic_status(struct echoaudio *chip);
35static int set_sample_rate(struct echoaudio *chip, u32 rate);
36static int set_input_clock(struct echoaudio *chip, u16 clock);
37static int set_professional_spdif(struct echoaudio *chip, char prof);
38static int set_phantom_power(struct echoaudio *chip, char on);
39static int write_control_reg(struct echoaudio *chip, u32 ctl, u32 frq,
40 char force);
41
42#include <linux/irq.h>
43
44static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
45{
46 int err;
47
48 local_irq_enable();
49 DE_INIT(("init_hw() - Echo3G\n"));
50 snd_assert((subdevice_id & 0xfff0) == ECHO3G, return -ENODEV);
51
52 if ((err = init_dsp_comm_page(chip))) {
53 DE_INIT(("init_hw - could not initialize DSP comm page\n"));
54 return err;
55 }
56
57 chip->comm_page->e3g_frq_register =
58 __constant_cpu_to_le32((E3G_MAGIC_NUMBER / 48000) - 2);
59 chip->device_id = device_id;
60 chip->subdevice_id = subdevice_id;
61 chip->bad_board = TRUE;
62 chip->has_midi = TRUE;
63 chip->dsp_code_to_load = &card_fw[FW_ECHO3G_DSP];
64
65 /* Load the DSP code and the ASIC on the PCI card and get
66 what type of external box is attached */
67 err = load_firmware(chip);
68
69 if (err < 0) {
70 return err;
71 } else if (err == E3G_GINA3G_BOX_TYPE) {
72 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
73 ECHO_CLOCK_BIT_SPDIF |
74 ECHO_CLOCK_BIT_ADAT;
75 chip->card_name = "Gina3G";
76 chip->px_digital_out = chip->bx_digital_out = 6;
77 chip->px_analog_in = chip->bx_analog_in = 14;
78 chip->px_digital_in = chip->bx_digital_in = 16;
79 chip->px_num = chip->bx_num = 24;
80 chip->has_phantom_power = TRUE;
81 chip->hasnt_input_nominal_level = TRUE;
82 } else if (err == E3G_LAYLA3G_BOX_TYPE) {
83 chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |
84 ECHO_CLOCK_BIT_SPDIF |
85 ECHO_CLOCK_BIT_ADAT |
86 ECHO_CLOCK_BIT_WORD;
87 chip->card_name = "Layla3G";
88 chip->px_digital_out = chip->bx_digital_out = 8;
89 chip->px_analog_in = chip->bx_analog_in = 16;
90 chip->px_digital_in = chip->bx_digital_in = 24;
91 chip->px_num = chip->bx_num = 32;
92 } else {
93 return -ENODEV;
94 }
95
96 chip->digital_modes = ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
97 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
98 ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
99 chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
100 chip->professional_spdif = FALSE;
101 chip->non_audio_spdif = FALSE;
102 chip->bad_board = FALSE;
103
104 if ((err = init_line_levels(chip)) < 0)
105 return err;
106 err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
107 snd_assert(err >= 0, return err);
108 err = set_phantom_power(chip, 0);
109 snd_assert(err >= 0, return err);
110 err = set_professional_spdif(chip, TRUE);
111
112 DE_INIT(("init_hw done\n"));
113 return err;
114}
115
116
117
118static int set_phantom_power(struct echoaudio *chip, char on)
119{
120 u32 control_reg = le32_to_cpu(chip->comm_page->control_register);
121
122 if (on)
123 control_reg |= E3G_PHANTOM_POWER;
124 else
125 control_reg &= ~E3G_PHANTOM_POWER;
126
127 chip->phantom_power = on;
128 return write_control_reg(chip, control_reg,
129 le32_to_cpu(chip->comm_page->e3g_frq_register),
130 0);
131}