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(CONFIG_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 if (trace_init)
195 printk ("WaveFront hardware version %d.%d\n", tmp1, tmp2);
196
197 if (!maui_write (0x9F))
198 return 0;
199 if ((tmp1 = maui_read ()) == -1 || (tmp2 = maui_read ()) == -1)
200 return 0;
201
202 if (trace_init)
203 printk ("WaveFront firmware version %d.%d\n", tmp1, tmp2);
204
205 if (!maui_write (0x85))
206 return 0;
207 tmp1 = 0;
208 for (i = 0; i < 4; i++)
209 {
210 tmp1 |= maui_read () << (7 * i);
211 }
212 if (trace_init)
213 printk ("Available DRAM %dk\n", tmp1 / 1024);
214
215 request_region (hw_config->io_base + 2, 6, "Maui");
216
217 for (i = 0; i < 1000; i++)
218 if (probe_mpu401 (hw_config))
219 break;
220
221 return probe_mpu401 (hw_config);
222 }
223
224 long
225 attach_maui (long mem_start, struct address_info *hw_config)
226 {
227 int this_dev = num_midis;
228
229 conf_printf ("Maui", hw_config);
230
231 hw_config->irq *= -1;
232 mem_start = attach_mpu401 (mem_start, hw_config);
233
234 if (num_midis > this_dev)
235 {
236 struct synth_operations *synth;
237
238
239
240
241
242
243 synth = midi_devs[this_dev]->converter;
244
245 if (synth != NULL)
246 {
247 orig_load_patch = synth->load_patch;
248 synth->load_patch = &maui_load_patch;
249 }
250 else
251 printk ("Maui: Can't install patch loader\n");
252 }
253 return mem_start;
254 }
255
256 void
257 unload_maui (struct address_info *hw_config)
258 {
259 int irq = hw_config->irq;
260
261 release_region (hw_config->io_base + 2, 6);
262
263 unload_mpu401 (hw_config);
264
265 if (irq < 0)
266 irq = -irq;
267
268 if (irq > 0)
269 snd_release_irq (irq);
270 }
271
272
273 #endif