blob: 3d4f899285ef666f151b1265a83fac17a4975a1b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02002 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * I/O routines for GF1/InterWave synthesizer chips
4 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#include <sound/driver.h>
23#include <linux/delay.h>
24#include <linux/time.h>
25#include <sound/core.h>
26#include <sound/gus.h>
27
Takashi Iwai5e2da202005-11-17 14:36:44 +010028void snd_gf1_delay(struct snd_gus_card * gus)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029{
30 int i;
31
32 for (i = 0; i < 6; i++) {
33 mb();
34 inb(GUSP(gus, DRAM));
35 }
36}
37
38/*
39 * =======================================================================
40 */
41
42/*
43 * ok.. stop of control registers (wave & ramp) need some special things..
44 * big UltraClick (tm) elimination...
45 */
46
Takashi Iwai5e2da202005-11-17 14:36:44 +010047static inline void __snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
49 unsigned char value;
50
51 outb(reg | 0x80, gus->gf1.reg_regsel);
52 mb();
53 value = inb(gus->gf1.reg_data8);
54 mb();
55 outb(reg, gus->gf1.reg_regsel);
56 mb();
57 outb((value | 0x03) & ~(0x80 | 0x20), gus->gf1.reg_data8);
58 mb();
59}
60
Takashi Iwai5e2da202005-11-17 14:36:44 +010061static inline void __snd_gf1_write8(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 unsigned char reg,
63 unsigned char data)
64{
65 outb(reg, gus->gf1.reg_regsel);
66 mb();
67 outb(data, gus->gf1.reg_data8);
68 mb();
69}
70
Takashi Iwai5e2da202005-11-17 14:36:44 +010071static inline unsigned char __snd_gf1_look8(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 unsigned char reg)
73{
74 outb(reg, gus->gf1.reg_regsel);
75 mb();
76 return inb(gus->gf1.reg_data8);
77}
78
Takashi Iwai5e2da202005-11-17 14:36:44 +010079static inline void __snd_gf1_write16(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 unsigned char reg, unsigned int data)
81{
82 outb(reg, gus->gf1.reg_regsel);
83 mb();
84 outw((unsigned short) data, gus->gf1.reg_data16);
85 mb();
86}
87
Takashi Iwai5e2da202005-11-17 14:36:44 +010088static inline unsigned short __snd_gf1_look16(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 unsigned char reg)
90{
91 outb(reg, gus->gf1.reg_regsel);
92 mb();
93 return inw(gus->gf1.reg_data16);
94}
95
Takashi Iwai5e2da202005-11-17 14:36:44 +010096static inline void __snd_gf1_adlib_write(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 unsigned char reg, unsigned char data)
98{
99 outb(reg, gus->gf1.reg_timerctrl);
100 inb(gus->gf1.reg_timerctrl);
101 inb(gus->gf1.reg_timerctrl);
102 outb(data, gus->gf1.reg_timerdata);
103 inb(gus->gf1.reg_timerctrl);
104 inb(gus->gf1.reg_timerctrl);
105}
106
Takashi Iwai5e2da202005-11-17 14:36:44 +0100107static inline void __snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 unsigned int addr, int w_16bit)
109{
110 if (gus->gf1.enh_mode) {
111 if (w_16bit)
112 addr = ((addr >> 1) & ~0x0000000f) | (addr & 0x0000000f);
113 __snd_gf1_write8(gus, SNDRV_GF1_VB_UPPER_ADDRESS, (unsigned char) ((addr >> 26) & 0x03));
114 } else if (w_16bit)
115 addr = (addr & 0x00c0000f) | ((addr & 0x003ffff0) >> 1);
116 __snd_gf1_write16(gus, reg, (unsigned short) (addr >> 11));
117 __snd_gf1_write16(gus, reg + 1, (unsigned short) (addr << 5));
118}
119
Takashi Iwai5e2da202005-11-17 14:36:44 +0100120static inline unsigned int __snd_gf1_read_addr(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 unsigned char reg, short w_16bit)
122{
123 unsigned int res;
124
125 res = ((unsigned int) __snd_gf1_look16(gus, reg | 0x80) << 11) & 0xfff800;
126 res |= ((unsigned int) __snd_gf1_look16(gus, (reg + 1) | 0x80) >> 5) & 0x0007ff;
127 if (gus->gf1.enh_mode) {
128 res |= (unsigned int) __snd_gf1_look8(gus, SNDRV_GF1_VB_UPPER_ADDRESS | 0x80) << 26;
129 if (w_16bit)
130 res = ((res << 1) & 0xffffffe0) | (res & 0x0000000f);
131 } else if (w_16bit)
132 res = ((res & 0x001ffff0) << 1) | (res & 0x00c0000f);
133 return res;
134}
135
136
137/*
138 * =======================================================================
139 */
140
Takashi Iwai5e2da202005-11-17 14:36:44 +0100141void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142{
143 __snd_gf1_ctrl_stop(gus, reg);
144}
145
Takashi Iwai5e2da202005-11-17 14:36:44 +0100146void snd_gf1_write8(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 unsigned char reg,
148 unsigned char data)
149{
150 __snd_gf1_write8(gus, reg, data);
151}
152
Takashi Iwai5e2da202005-11-17 14:36:44 +0100153unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154{
155 return __snd_gf1_look8(gus, reg);
156}
157
Takashi Iwai5e2da202005-11-17 14:36:44 +0100158void snd_gf1_write16(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 unsigned char reg,
160 unsigned int data)
161{
162 __snd_gf1_write16(gus, reg, data);
163}
164
Takashi Iwai5e2da202005-11-17 14:36:44 +0100165unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166{
167 return __snd_gf1_look16(gus, reg);
168}
169
Takashi Iwai5e2da202005-11-17 14:36:44 +0100170void snd_gf1_adlib_write(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 unsigned char reg,
172 unsigned char data)
173{
174 __snd_gf1_adlib_write(gus, reg, data);
175}
176
Takashi Iwai5e2da202005-11-17 14:36:44 +0100177void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 unsigned int addr, short w_16bit)
179{
180 __snd_gf1_write_addr(gus, reg, addr, w_16bit);
181}
182
Takashi Iwai5e2da202005-11-17 14:36:44 +0100183unsigned int snd_gf1_read_addr(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 unsigned char reg,
185 short w_16bit)
186{
187 return __snd_gf1_read_addr(gus, reg, w_16bit);
188}
189
190/*
191
192 */
193
Takashi Iwai5e2da202005-11-17 14:36:44 +0100194void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195{
196 unsigned long flags;
197
198 spin_lock_irqsave(&gus->reg_lock, flags);
199 __snd_gf1_ctrl_stop(gus, reg);
200 spin_unlock_irqrestore(&gus->reg_lock, flags);
201}
202
Takashi Iwai5e2da202005-11-17 14:36:44 +0100203void snd_gf1_i_write8(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 unsigned char reg,
205 unsigned char data)
206{
207 unsigned long flags;
208
209 spin_lock_irqsave(&gus->reg_lock, flags);
210 __snd_gf1_write8(gus, reg, data);
211 spin_unlock_irqrestore(&gus->reg_lock, flags);
212}
213
Takashi Iwai5e2da202005-11-17 14:36:44 +0100214unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215{
216 unsigned long flags;
217 unsigned char res;
218
219 spin_lock_irqsave(&gus->reg_lock, flags);
220 res = __snd_gf1_look8(gus, reg);
221 spin_unlock_irqrestore(&gus->reg_lock, flags);
222 return res;
223}
224
Takashi Iwai5e2da202005-11-17 14:36:44 +0100225void snd_gf1_i_write16(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 unsigned char reg,
227 unsigned int data)
228{
229 unsigned long flags;
230
231 spin_lock_irqsave(&gus->reg_lock, flags);
232 __snd_gf1_write16(gus, reg, data);
233 spin_unlock_irqrestore(&gus->reg_lock, flags);
234}
235
Takashi Iwai5e2da202005-11-17 14:36:44 +0100236unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
238 unsigned long flags;
239 unsigned short res;
240
241 spin_lock_irqsave(&gus->reg_lock, flags);
242 res = __snd_gf1_look16(gus, reg);
243 spin_unlock_irqrestore(&gus->reg_lock, flags);
244 return res;
245}
246
Adrian Bunk209ac852005-05-23 10:29:53 +0200247#if 0
248
Takashi Iwai5e2da202005-11-17 14:36:44 +0100249void snd_gf1_i_adlib_write(struct snd_gus_card * gus,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 unsigned char reg,
251 unsigned char data)
252{
253 unsigned long flags;
254
255 spin_lock_irqsave(&gus->reg_lock, flags);
256 __snd_gf1_adlib_write(gus, reg, data);
257 spin_unlock_irqrestore(&gus->reg_lock, flags);
258}
259
Takashi Iwai5e2da202005-11-17 14:36:44 +0100260void snd_gf1_i_write_addr(struct snd_gus_card * gus, unsigned char reg,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 unsigned int addr, short w_16bit)
262{
263 unsigned long flags;
264
265 spin_lock_irqsave(&gus->reg_lock, flags);
266 __snd_gf1_write_addr(gus, reg, addr, w_16bit);
267 spin_unlock_irqrestore(&gus->reg_lock, flags);
268}
269
Adrian Bunk209ac852005-05-23 10:29:53 +0200270#endif /* 0 */
271
Clemens Ladischa53fc182005-08-11 15:59:17 +0200272#ifdef CONFIG_SND_DEBUG
Takashi Iwai5e2da202005-11-17 14:36:44 +0100273static unsigned int snd_gf1_i_read_addr(struct snd_gus_card * gus,
Clemens Ladischa53fc182005-08-11 15:59:17 +0200274 unsigned char reg, short w_16bit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275{
276 unsigned int res;
277 unsigned long flags;
278
279 spin_lock_irqsave(&gus->reg_lock, flags);
280 res = __snd_gf1_read_addr(gus, reg, w_16bit);
281 spin_unlock_irqrestore(&gus->reg_lock, flags);
282 return res;
283}
Clemens Ladischa53fc182005-08-11 15:59:17 +0200284#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286/*
287
288 */
289
Takashi Iwai5e2da202005-11-17 14:36:44 +0100290void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291{
292 outb(0x43, gus->gf1.reg_regsel);
293 mb();
294 outw((unsigned short) addr, gus->gf1.reg_data16);
295 mb();
296 outb(0x44, gus->gf1.reg_regsel);
297 mb();
298 outb((unsigned char) (addr >> 16), gus->gf1.reg_data8);
299 mb();
300}
301
Takashi Iwai5e2da202005-11-17 14:36:44 +0100302void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303{
304 unsigned long flags;
305
306 spin_lock_irqsave(&gus->reg_lock, flags);
307 outb(SNDRV_GF1_GW_DRAM_IO_LOW, gus->gf1.reg_regsel);
308 mb();
309 outw((unsigned short) addr, gus->gf1.reg_data16);
310 mb();
311 outb(SNDRV_GF1_GB_DRAM_IO_HIGH, gus->gf1.reg_regsel);
312 mb();
313 outb((unsigned char) (addr >> 16), gus->gf1.reg_data8);
314 mb();
315 outb(data, gus->gf1.reg_dram);
316 spin_unlock_irqrestore(&gus->reg_lock, flags);
317}
318
Takashi Iwai5e2da202005-11-17 14:36:44 +0100319unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320{
321 unsigned long flags;
322 unsigned char res;
323
324 spin_lock_irqsave(&gus->reg_lock, flags);
325 outb(SNDRV_GF1_GW_DRAM_IO_LOW, gus->gf1.reg_regsel);
326 mb();
327 outw((unsigned short) addr, gus->gf1.reg_data16);
328 mb();
329 outb(SNDRV_GF1_GB_DRAM_IO_HIGH, gus->gf1.reg_regsel);
330 mb();
331 outb((unsigned char) (addr >> 16), gus->gf1.reg_data8);
332 mb();
333 res = inb(gus->gf1.reg_dram);
334 spin_unlock_irqrestore(&gus->reg_lock, flags);
335 return res;
336}
337
Adrian Bunk209ac852005-05-23 10:29:53 +0200338#if 0
339
Takashi Iwai5e2da202005-11-17 14:36:44 +0100340void snd_gf1_pokew(struct snd_gus_card * gus, unsigned int addr, unsigned short data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341{
342 unsigned long flags;
343
344#ifdef CONFIG_SND_DEBUG
345 if (!gus->interwave)
Takashi Iwai99b359b2005-10-20 18:26:44 +0200346 snd_printk(KERN_DEBUG "snd_gf1_pokew - GF1!!!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347#endif
348 spin_lock_irqsave(&gus->reg_lock, flags);
349 outb(SNDRV_GF1_GW_DRAM_IO_LOW, gus->gf1.reg_regsel);
350 mb();
351 outw((unsigned short) addr, gus->gf1.reg_data16);
352 mb();
353 outb(SNDRV_GF1_GB_DRAM_IO_HIGH, gus->gf1.reg_regsel);
354 mb();
355 outb((unsigned char) (addr >> 16), gus->gf1.reg_data8);
356 mb();
357 outb(SNDRV_GF1_GW_DRAM_IO16, gus->gf1.reg_regsel);
358 mb();
359 outw(data, gus->gf1.reg_data16);
360 spin_unlock_irqrestore(&gus->reg_lock, flags);
361}
362
Takashi Iwai5e2da202005-11-17 14:36:44 +0100363unsigned short snd_gf1_peekw(struct snd_gus_card * gus, unsigned int addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364{
365 unsigned long flags;
366 unsigned short res;
367
368#ifdef CONFIG_SND_DEBUG
369 if (!gus->interwave)
Takashi Iwai99b359b2005-10-20 18:26:44 +0200370 snd_printk(KERN_DEBUG "snd_gf1_peekw - GF1!!!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371#endif
372 spin_lock_irqsave(&gus->reg_lock, flags);
373 outb(SNDRV_GF1_GW_DRAM_IO_LOW, gus->gf1.reg_regsel);
374 mb();
375 outw((unsigned short) addr, gus->gf1.reg_data16);
376 mb();
377 outb(SNDRV_GF1_GB_DRAM_IO_HIGH, gus->gf1.reg_regsel);
378 mb();
379 outb((unsigned char) (addr >> 16), gus->gf1.reg_data8);
380 mb();
381 outb(SNDRV_GF1_GW_DRAM_IO16, gus->gf1.reg_regsel);
382 mb();
383 res = inw(gus->gf1.reg_data16);
384 spin_unlock_irqrestore(&gus->reg_lock, flags);
385 return res;
386}
387
Takashi Iwai5e2da202005-11-17 14:36:44 +0100388void snd_gf1_dram_setmem(struct snd_gus_card * gus, unsigned int addr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 unsigned short value, unsigned int count)
390{
391 unsigned long port;
392 unsigned long flags;
393
394#ifdef CONFIG_SND_DEBUG
395 if (!gus->interwave)
Takashi Iwai99b359b2005-10-20 18:26:44 +0200396 snd_printk(KERN_DEBUG "snd_gf1_dram_setmem - GF1!!!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397#endif
398 addr &= ~1;
399 count >>= 1;
400 port = GUSP(gus, GF1DATALOW);
401 spin_lock_irqsave(&gus->reg_lock, flags);
402 outb(SNDRV_GF1_GW_DRAM_IO_LOW, gus->gf1.reg_regsel);
403 mb();
404 outw((unsigned short) addr, gus->gf1.reg_data16);
405 mb();
406 outb(SNDRV_GF1_GB_DRAM_IO_HIGH, gus->gf1.reg_regsel);
407 mb();
408 outb((unsigned char) (addr >> 16), gus->gf1.reg_data8);
409 mb();
410 outb(SNDRV_GF1_GW_DRAM_IO16, gus->gf1.reg_regsel);
411 while (count--)
412 outw(value, port);
413 spin_unlock_irqrestore(&gus->reg_lock, flags);
414}
415
Adrian Bunk209ac852005-05-23 10:29:53 +0200416#endif /* 0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417
Takashi Iwai5e2da202005-11-17 14:36:44 +0100418void snd_gf1_select_active_voices(struct snd_gus_card * gus)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419{
420 unsigned short voices;
421
422 static unsigned short voices_tbl[32 - 14 + 1] =
423 {
424 44100, 41160, 38587, 36317, 34300, 32494, 30870, 29400, 28063, 26843,
425 25725, 24696, 23746, 22866, 22050, 21289, 20580, 19916, 19293
426 };
427
428 voices = gus->gf1.active_voices;
429 if (voices > 32)
430 voices = 32;
431 if (voices < 14)
432 voices = 14;
433 if (gus->gf1.enh_mode)
434 voices = 32;
435 gus->gf1.active_voices = voices;
436 gus->gf1.playback_freq =
437 gus->gf1.enh_mode ? 44100 : voices_tbl[voices - 14];
438 if (!gus->gf1.enh_mode) {
439 snd_gf1_i_write8(gus, SNDRV_GF1_GB_ACTIVE_VOICES, 0xc0 | (voices - 1));
440 udelay(100);
441 }
442}
443
444#ifdef CONFIG_SND_DEBUG
445
Takashi Iwai5e2da202005-11-17 14:36:44 +0100446void snd_gf1_print_voice_registers(struct snd_gus_card * gus)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447{
448 unsigned char mode;
449 int voice, ctrl;
450
451 voice = gus->gf1.active_voice;
Takashi Iwai99b359b2005-10-20 18:26:44 +0200452 printk(KERN_INFO " -%i- GF1 voice ctrl, ramp ctrl = 0x%x, 0x%x\n", voice, ctrl = snd_gf1_i_read8(gus, 0), snd_gf1_i_read8(gus, 0x0d));
453 printk(KERN_INFO " -%i- GF1 frequency = 0x%x\n", voice, snd_gf1_i_read16(gus, 1));
454 printk(KERN_INFO " -%i- GF1 loop start, end = 0x%x (0x%x), 0x%x (0x%x)\n", voice, snd_gf1_i_read_addr(gus, 2, ctrl & 4), snd_gf1_i_read_addr(gus, 2, (ctrl & 4) ^ 4), snd_gf1_i_read_addr(gus, 4, ctrl & 4), snd_gf1_i_read_addr(gus, 4, (ctrl & 4) ^ 4));
455 printk(KERN_INFO " -%i- GF1 ramp start, end, rate = 0x%x, 0x%x, 0x%x\n", voice, snd_gf1_i_read8(gus, 7), snd_gf1_i_read8(gus, 8), snd_gf1_i_read8(gus, 6));
456 printk(KERN_INFO" -%i- GF1 volume = 0x%x\n", voice, snd_gf1_i_read16(gus, 9));
457 printk(KERN_INFO " -%i- GF1 position = 0x%x (0x%x)\n", voice, snd_gf1_i_read_addr(gus, 0x0a, ctrl & 4), snd_gf1_i_read_addr(gus, 0x0a, (ctrl & 4) ^ 4));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 if (gus->interwave && snd_gf1_i_read8(gus, 0x19) & 0x01) { /* enhanced mode */
459 mode = snd_gf1_i_read8(gus, 0x15);
Takashi Iwai99b359b2005-10-20 18:26:44 +0200460 printk(KERN_INFO " -%i- GFA1 mode = 0x%x\n", voice, mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 if (mode & 0x01) { /* Effect processor */
Takashi Iwai99b359b2005-10-20 18:26:44 +0200462 printk(KERN_INFO " -%i- GFA1 effect address = 0x%x\n", voice, snd_gf1_i_read_addr(gus, 0x11, ctrl & 4));
463 printk(KERN_INFO " -%i- GFA1 effect volume = 0x%x\n", voice, snd_gf1_i_read16(gus, 0x16));
464 printk(KERN_INFO " -%i- GFA1 effect volume final = 0x%x\n", voice, snd_gf1_i_read16(gus, 0x1d));
465 printk(KERN_INFO " -%i- GFA1 effect acumulator = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x14));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 }
467 if (mode & 0x20) {
Takashi Iwai99b359b2005-10-20 18:26:44 +0200468 printk(KERN_INFO " -%i- GFA1 left offset = 0x%x (%i)\n", voice, snd_gf1_i_read16(gus, 0x13), snd_gf1_i_read16(gus, 0x13) >> 4);
469 printk(KERN_INFO " -%i- GFA1 left offset final = 0x%x (%i)\n", voice, snd_gf1_i_read16(gus, 0x1c), snd_gf1_i_read16(gus, 0x1c) >> 4);
470 printk(KERN_INFO " -%i- GFA1 right offset = 0x%x (%i)\n", voice, snd_gf1_i_read16(gus, 0x0c), snd_gf1_i_read16(gus, 0x0c) >> 4);
471 printk(KERN_INFO " -%i- GFA1 right offset final = 0x%x (%i)\n", voice, snd_gf1_i_read16(gus, 0x1b), snd_gf1_i_read16(gus, 0x1b) >> 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 } else
Takashi Iwai99b359b2005-10-20 18:26:44 +0200473 printk(KERN_INFO " -%i- GF1 pan = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x0c));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 } else
Takashi Iwai99b359b2005-10-20 18:26:44 +0200475 printk(KERN_INFO " -%i- GF1 pan = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x0c));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476}
477
Adrian Bunk209ac852005-05-23 10:29:53 +0200478#if 0
479
Takashi Iwai5e2da202005-11-17 14:36:44 +0100480void snd_gf1_print_global_registers(struct snd_gus_card * gus)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481{
482 unsigned char global_mode = 0x00;
483
Takashi Iwai99b359b2005-10-20 18:26:44 +0200484 printk(KERN_INFO " -G- GF1 active voices = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_ACTIVE_VOICES));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 if (gus->interwave) {
486 global_mode = snd_gf1_i_read8(gus, SNDRV_GF1_GB_GLOBAL_MODE);
Takashi Iwai99b359b2005-10-20 18:26:44 +0200487 printk(KERN_INFO " -G- GF1 global mode = 0x%x\n", global_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 }
489 if (global_mode & 0x02) /* LFO enabled? */
Takashi Iwai99b359b2005-10-20 18:26:44 +0200490 printk(KERN_INFO " -G- GF1 LFO base = 0x%x\n", snd_gf1_i_look16(gus, SNDRV_GF1_GW_LFO_BASE));
491 printk(KERN_INFO " -G- GF1 voices IRQ read = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_VOICES_IRQ_READ));
492 printk(KERN_INFO " -G- GF1 DRAM DMA control = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_DRAM_DMA_CONTROL));
493 printk(KERN_INFO " -G- GF1 DRAM DMA high/low = 0x%x/0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_DRAM_DMA_HIGH), snd_gf1_i_read16(gus, SNDRV_GF1_GW_DRAM_DMA_LOW));
494 printk(KERN_INFO " -G- GF1 DRAM IO high/low = 0x%x/0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_DRAM_IO_HIGH), snd_gf1_i_read16(gus, SNDRV_GF1_GW_DRAM_IO_LOW));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 if (!gus->interwave)
Takashi Iwai99b359b2005-10-20 18:26:44 +0200496 printk(KERN_INFO " -G- GF1 record DMA control = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL));
497 printk(KERN_INFO " -G- GF1 DRAM IO 16 = 0x%x\n", snd_gf1_i_look16(gus, SNDRV_GF1_GW_DRAM_IO16));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 if (gus->gf1.enh_mode) {
Takashi Iwai99b359b2005-10-20 18:26:44 +0200499 printk(KERN_INFO " -G- GFA1 memory config = 0x%x\n", snd_gf1_i_look16(gus, SNDRV_GF1_GW_MEMORY_CONFIG));
500 printk(KERN_INFO " -G- GFA1 memory control = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_MEMORY_CONTROL));
501 printk(KERN_INFO " -G- GFA1 FIFO record base = 0x%x\n", snd_gf1_i_look16(gus, SNDRV_GF1_GW_FIFO_RECORD_BASE_ADDR));
502 printk(KERN_INFO " -G- GFA1 FIFO playback base = 0x%x\n", snd_gf1_i_look16(gus, SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR));
503 printk(KERN_INFO " -G- GFA1 interleave control = 0x%x\n", snd_gf1_i_look16(gus, SNDRV_GF1_GW_INTERLEAVE));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 }
505}
506
Takashi Iwai5e2da202005-11-17 14:36:44 +0100507void snd_gf1_print_setup_registers(struct snd_gus_card * gus)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508{
Takashi Iwai99b359b2005-10-20 18:26:44 +0200509 printk(KERN_INFO " -S- mix control = 0x%x\n", inb(GUSP(gus, MIXCNTRLREG)));
510 printk(KERN_INFO " -S- IRQ status = 0x%x\n", inb(GUSP(gus, IRQSTAT)));
511 printk(KERN_INFO " -S- timer control = 0x%x\n", inb(GUSP(gus, TIMERCNTRL)));
512 printk(KERN_INFO " -S- timer data = 0x%x\n", inb(GUSP(gus, TIMERDATA)));
513 printk(KERN_INFO " -S- status read = 0x%x\n", inb(GUSP(gus, REGCNTRLS)));
514 printk(KERN_INFO " -S- Sound Blaster control = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL));
515 printk(KERN_INFO " -S- AdLib timer 1/2 = 0x%x/0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_ADLIB_TIMER_1), snd_gf1_i_look8(gus, SNDRV_GF1_GB_ADLIB_TIMER_2));
516 printk(KERN_INFO " -S- reset = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_RESET));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 if (gus->interwave) {
Takashi Iwai99b359b2005-10-20 18:26:44 +0200518 printk(KERN_INFO " -S- compatibility = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_COMPATIBILITY));
519 printk(KERN_INFO " -S- decode control = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_DECODE_CONTROL));
520 printk(KERN_INFO " -S- version number = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_VERSION_NUMBER));
521 printk(KERN_INFO " -S- MPU-401 emul. control A/B = 0x%x/0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_MPU401_CONTROL_A), snd_gf1_i_look8(gus, SNDRV_GF1_GB_MPU401_CONTROL_B));
522 printk(KERN_INFO " -S- emulation IRQ = 0x%x\n", snd_gf1_i_look8(gus, SNDRV_GF1_GB_EMULATION_IRQ));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 }
524}
525
Takashi Iwai5e2da202005-11-17 14:36:44 +0100526void snd_gf1_peek_print_block(struct snd_gus_card * gus, unsigned int addr, int count, int w_16bit)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
528 if (!w_16bit) {
529 while (count-- > 0)
530 printk(count > 0 ? "%02x:" : "%02x", snd_gf1_peek(gus, addr++));
531 } else {
532 while (count-- > 0) {
533 printk(count > 0 ? "%04x:" : "%04x", snd_gf1_peek(gus, addr) | (snd_gf1_peek(gus, addr + 1) << 8));
534 addr += 2;
535 }
536 }
537}
538
Adrian Bunk209ac852005-05-23 10:29:53 +0200539#endif /* 0 */
540
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541#endif