23 #include <linux/time.h>
31 for (i = 0; i < 6; i++) {
46 static inline void __snd_gf1_ctrl_stop(
struct snd_gus_card * gus,
unsigned char reg)
50 outb(reg | 0x80, gus->
gf1.reg_regsel);
52 value =
inb(gus->
gf1.reg_data8);
56 outb((value | 0x03) & ~(0x80 | 0x20), gus->
gf1.reg_data8);
60 static inline void __snd_gf1_write8(
struct snd_gus_card * gus,
70 static inline unsigned char __snd_gf1_look8(
struct snd_gus_card * gus,
75 return inb(gus->
gf1.reg_data8);
78 static inline void __snd_gf1_write16(
struct snd_gus_card * gus,
79 unsigned char reg,
unsigned int data)
83 outw((
unsigned short) data, gus->
gf1.reg_data16);
87 static inline unsigned short __snd_gf1_look16(
struct snd_gus_card * gus,
92 return inw(gus->
gf1.reg_data16);
95 static inline void __snd_gf1_adlib_write(
struct snd_gus_card * gus,
96 unsigned char reg,
unsigned char data)
98 outb(reg, gus->
gf1.reg_timerctrl);
99 inb(gus->
gf1.reg_timerctrl);
100 inb(gus->
gf1.reg_timerctrl);
101 outb(data, gus->
gf1.reg_timerdata);
102 inb(gus->
gf1.reg_timerctrl);
103 inb(gus->
gf1.reg_timerctrl);
106 static inline void __snd_gf1_write_addr(
struct snd_gus_card * gus,
unsigned char reg,
107 unsigned int addr,
int w_16bit)
109 if (gus->
gf1.enh_mode) {
111 addr = ((addr >> 1) & ~0x0000000f) | (addr & 0x0000000f);
114 addr = (addr & 0x00c0000f) | ((addr & 0x003ffff0) >> 1);
115 __snd_gf1_write16(gus, reg, (
unsigned short) (addr >> 11));
116 __snd_gf1_write16(gus, reg + 1, (
unsigned short) (addr << 5));
119 static inline unsigned int __snd_gf1_read_addr(
struct snd_gus_card * gus,
120 unsigned char reg,
short w_16bit)
124 res = ((
unsigned int) __snd_gf1_look16(gus, reg | 0x80) << 11) & 0xfff800;
125 res |= ((
unsigned int) __snd_gf1_look16(gus, (reg + 1) | 0x80) >> 5) & 0x0007ff;
126 if (gus->
gf1.enh_mode) {
129 res = ((res << 1) & 0xffffffe0) | (res & 0x0000000f);
131 res = ((res & 0x001ffff0) << 1) | (res & 0x00c0000f);
142 __snd_gf1_ctrl_stop(gus, reg);
149 __snd_gf1_write8(gus, reg, data);
154 return __snd_gf1_look8(gus, reg);
161 __snd_gf1_write16(gus, reg, data);
166 return __snd_gf1_look16(gus, reg);
173 __snd_gf1_adlib_write(gus, reg, data);
177 unsigned int addr,
short w_16bit)
179 __snd_gf1_write_addr(gus, reg, addr, w_16bit);
186 return __snd_gf1_read_addr(gus, reg, w_16bit);
198 __snd_gf1_ctrl_stop(gus, reg);
199 spin_unlock_irqrestore(&gus->
reg_lock, flags);
209 __snd_gf1_write8(gus, reg, data);
210 spin_unlock_irqrestore(&gus->
reg_lock, flags);
219 res = __snd_gf1_look8(gus, reg);
220 spin_unlock_irqrestore(&gus->
reg_lock, flags);
231 __snd_gf1_write16(gus, reg, data);
232 spin_unlock_irqrestore(&gus->
reg_lock, flags);
241 res = __snd_gf1_look16(gus, reg);
242 spin_unlock_irqrestore(&gus->
reg_lock, flags);
255 __snd_gf1_adlib_write(gus, reg, data);
256 spin_unlock_irqrestore(&gus->
reg_lock, flags);
259 void snd_gf1_i_write_addr(
struct snd_gus_card * gus,
unsigned char reg,
260 unsigned int addr,
short w_16bit)
265 __snd_gf1_write_addr(gus, reg, addr, w_16bit);
266 spin_unlock_irqrestore(&gus->
reg_lock, flags);
271 #ifdef CONFIG_SND_DEBUG
272 static unsigned int snd_gf1_i_read_addr(
struct snd_gus_card * gus,
273 unsigned char reg,
short w_16bit)
279 res = __snd_gf1_read_addr(gus, reg, w_16bit);
280 spin_unlock_irqrestore(&gus->
reg_lock, flags);
291 outb(0x43, gus->
gf1.reg_regsel);
293 outw((
unsigned short) addr, gus->
gf1.reg_data16);
295 outb(0x44, gus->
gf1.reg_regsel);
297 outb((
unsigned char) (addr >> 16), gus->
gf1.reg_data8);
308 outw((
unsigned short) addr, gus->
gf1.reg_data16);
312 outb((
unsigned char) (addr >> 16), gus->
gf1.reg_data8);
315 spin_unlock_irqrestore(&gus->
reg_lock, flags);
326 outw((
unsigned short) addr, gus->
gf1.reg_data16);
330 outb((
unsigned char) (addr >> 16), gus->
gf1.reg_data8);
332 res =
inb(gus->
gf1.reg_dram);
333 spin_unlock_irqrestore(&gus->
reg_lock, flags);
339 void snd_gf1_pokew(
struct snd_gus_card * gus,
unsigned int addr,
unsigned short data)
343 #ifdef CONFIG_SND_DEBUG
350 outw((
unsigned short) addr, gus->
gf1.reg_data16);
354 outb((
unsigned char) (addr >> 16), gus->
gf1.reg_data8);
358 outw(data, gus->
gf1.reg_data16);
359 spin_unlock_irqrestore(&gus->
reg_lock, flags);
362 unsigned short snd_gf1_peekw(
struct snd_gus_card * gus,
unsigned int addr)
367 #ifdef CONFIG_SND_DEBUG
374 outw((
unsigned short) addr, gus->
gf1.reg_data16);
378 outb((
unsigned char) (addr >> 16), gus->
gf1.reg_data8);
382 res =
inw(gus->
gf1.reg_data16);
383 spin_unlock_irqrestore(&gus->
reg_lock, flags);
387 void snd_gf1_dram_setmem(
struct snd_gus_card * gus,
unsigned int addr,
388 unsigned short value,
unsigned int count)
393 #ifdef CONFIG_SND_DEBUG
399 port =
GUSP(gus, GF1DATALOW);
403 outw((
unsigned short) addr, gus->
gf1.reg_data16);
407 outb((
unsigned char) (addr >> 16), gus->
gf1.reg_data8);
412 spin_unlock_irqrestore(&gus->
reg_lock, flags);
419 unsigned short voices;
421 static unsigned short voices_tbl[32 - 14 + 1] =
423 44100, 41160, 38587, 36317, 34300, 32494, 30870, 29400, 28063, 26843,
424 25725, 24696, 23746, 22866, 22050, 21289, 20580, 19916, 19293
427 voices = gus->
gf1.active_voices;
432 if (gus->
gf1.enh_mode)
434 gus->
gf1.active_voices = voices;
435 gus->
gf1.playback_freq =
436 gus->
gf1.enh_mode ? 44100 : voices_tbl[voices - 14];
437 if (!gus->
gf1.enh_mode) {
443 #ifdef CONFIG_SND_DEBUG
445 void snd_gf1_print_voice_registers(
struct snd_gus_card * gus)
450 voice = gus->
gf1.active_voice;
451 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));
452 printk(
KERN_INFO " -%i- GF1 frequency = 0x%x\n", voice, snd_gf1_i_read16(gus, 1));
453 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));
454 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));
455 printk(
KERN_INFO" -%i- GF1 volume = 0x%x\n", voice, snd_gf1_i_read16(gus, 9));
456 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));
457 if (gus->
interwave && snd_gf1_i_read8(gus, 0x19) & 0x01) {
458 mode = snd_gf1_i_read8(gus, 0x15);
461 printk(
KERN_INFO " -%i- GFA1 effect address = 0x%x\n", voice, snd_gf1_i_read_addr(gus, 0x11, ctrl & 4));
462 printk(
KERN_INFO " -%i- GFA1 effect volume = 0x%x\n", voice, snd_gf1_i_read16(gus, 0x16));
463 printk(
KERN_INFO " -%i- GFA1 effect volume final = 0x%x\n", voice, snd_gf1_i_read16(gus, 0x1d));
464 printk(
KERN_INFO " -%i- GFA1 effect acumulator = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x14));
467 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);
468 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);
469 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);
470 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);
472 printk(
KERN_INFO " -%i- GF1 pan = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x0c));
474 printk(
KERN_INFO " -%i- GF1 pan = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x0c));
479 void snd_gf1_print_global_registers(
struct snd_gus_card * gus)
481 unsigned char global_mode = 0x00;
488 if (global_mode & 0x02)
497 if (gus->
gf1.enh_mode) {
506 void snd_gf1_print_setup_registers(
struct snd_gus_card * gus)
525 void snd_gf1_peek_print_block(
struct snd_gus_card * gus,
unsigned int addr,
int count,
int w_16bit)
531 while (count-- > 0) {