This source file includes following definitions.
- maui_read
- maui_write
- mauiintr
- maui_load_patch
- probe_maui
- attach_maui
- unload_maui
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #define USE_SEQ_MACROS
31 #define USE_SIMPLE_MACROS
32
33 #include "sound_config.h"
34
35 #if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_MAUI)
36
37 static int maui_base = 0x330;
38
39 static volatile int irq_ok = 0;
40 static sound_os_info *maui_osp;
41
42 #define HOST_DATA_PORT (maui_base + 2)
43 #define HOST_STAT_PORT (maui_base + 3)
44 #define HOST_CTRL_PORT (maui_base + 3)
45
46 #define STAT_TX_INTR 0x40
47 #define STAT_TX_AVAIL 0x20
48 #define STAT_TX_IENA 0x10
49 #define STAT_RX_INTR 0x04
50 #define STAT_RX_AVAIL 0x02
51 #define STAT_RX_IENA 0x01
52
53 static int (*orig_load_patch) (int dev, int format, const snd_rw_buf * addr,
54 int offs, int count, int pmgr_flag) = NULL;
55
56 static int
57 maui_read (void)
58 {
59 int timeout;
60
61 for (timeout = 0; timeout < 1000000; timeout++)
62 {
63 if (inb (HOST_STAT_PORT) & STAT_RX_AVAIL)
64 {
65 return inb (HOST_DATA_PORT);
66 }
67 }
68
69 printk ("Maui: Receive timeout\n");
70
71 return -1;
72 }
73
74 static int
75 maui_write (unsigned char data)
76 {
77 int timeout;
78
79 for (timeout = 0; timeout < 10000000; timeout++)
80 {
81 if (inb (HOST_STAT_PORT) & STAT_TX_AVAIL)
82 {
83 outb (data, HOST_DATA_PORT);
84 return 1;
85 }
86 }
87
88 printk ("Maui: Write timeout\n");
89
90 return 0;
91 }
92
93 void
94 mauiintr (int irq, struct pt_regs *dummy)
95 {
96 irq_ok = 1;
97 }
98
99
100 int
101 maui_load_patch (int dev, int format, const snd_rw_buf * addr,
102 int offs, int count, int pmgr_flag)
103 {
104
105 struct sysex_info header;
106 unsigned long left, src_offs;
107 int hdr_size = (unsigned long) &header.data[0] - (unsigned long) &header;
108 int i;
109
110 if (format == SYSEX_PATCH)
111 return orig_load_patch (dev, format, addr, offs, count, pmgr_flag);
112
113 if (format != MAUI_PATCH)
114 {
115 printk ("Maui: Unknown patch format\n");
116 }
117
118 if (count < hdr_size)
119 {
120 printk ("Maui error: Patch header too short\n");
121 return -EINVAL;
122 }
123
124 count -= hdr_size;
125
126
127
128
129
130
131 memcpy_fromfs (&((char *) &header)[offs], &((addr)[offs]), hdr_size - offs);
132
133 if (count < header.len)
134 {
135 printk ("Maui warning: Host command record too short (%d<%d)\n",
136 count, (int) header.len);
137 header.len = count;
138 }
139
140 left = header.len;
141 src_offs = 0;
142
143 for (i = 0; i < left; i++)
144 {
145 unsigned char data;
146
147 data = get_fs_byte (&((addr)[hdr_size + i]));
148 if (i == 0 && !(data & 0x80))
149 return -EINVAL;
150
151 if (maui_write (data) == -1)
152 return -EIO;
153 }
154
155 if ((i = maui_read ()) != 0x80)
156 {
157 if (i != -1)
158 printk ("Maui: Error status %02x\n", i);
159
160 return -EIO;
161 }
162
163 return 0;
164 }
165
166 int
167 probe_maui (struct address_info *hw_config)
168 {
169 int i;
170 int tmp1, tmp2;
171
172 if (check_region (hw_config->io_base, 8))
173 return 0;
174
175 maui_base = hw_config->io_base;
176 maui_osp = hw_config->osp;
177
178 if (snd_set_irq_handler (hw_config->irq, mauiintr, "Maui", maui_osp) < 0)
179 return 0;
180
181
182 if (!maui_write (0xCF))
183 {
184 snd_release_irq (hw_config->irq);
185 return 0;
186 }
187
188 if ((tmp1 = maui_read ()) == -1 || (tmp2 = maui_read ()) == -1)
189 {
190 snd_release_irq (hw_config->irq);
191 return 0;
192 }
193
194 printk ("WaveFront hardware version %d.%d\n", tmp1, tmp2);
195
196 if (!maui_write (0x9F))
197 return 0;
198 if ((tmp1 = maui_read ()) == -1 || (tmp2 = maui_read ()) == -1)
199 return 0;
200 printk ("WaveFront firmware version %d.%d\n", tmp1, tmp2);
201
202 if (!maui_write (0x85))
203 return 0;
204 tmp1 = 0;
205 for (i = 0; i < 4; i++)
206 {
207 tmp1 |= maui_read () << (7 * i);
208 }
209 printk ("Available DRAM %dk\n", tmp1 / 1024);
210
211 request_region (hw_config->io_base + 2, 6, "Maui");
212
213 for (i = 0; i < 1000; i++)
214 if (probe_mpu401 (hw_config))
215 break;
216
217 return probe_mpu401 (hw_config);
218 }
219
220 long
221 attach_maui (long mem_start, struct address_info *hw_config)
222 {
223 int this_dev = num_midis;
224
225 printk (" <Maui>");
226
227 hw_config->irq *= -1;
228 mem_start = attach_mpu401 (mem_start, hw_config);
229
230 if (num_midis > this_dev)
231 {
232 struct synth_operations *synth;
233
234
235
236
237
238
239 synth = midi_devs[this_dev]->converter;
240
241 if (synth != NULL)
242 {
243 orig_load_patch = synth->load_patch;
244 synth->load_patch = &maui_load_patch;
245 }
246 else
247 printk ("Maui: Can't install patch loader\n");
248 }
249 return mem_start;
250 }
251
252 void
253 unload_maui (struct address_info *hw_config)
254 {
255 int irq = hw_config->irq;
256
257 release_region (hw_config->io_base + 2, 6);
258
259 unload_mpu401 (hw_config);
260
261 if (irq < 0)
262 irq = -irq;
263
264 if (irq > 0)
265 snd_release_irq (irq);
266 }
267
268
269 #endif