31 #include <linux/module.h>
34 #include <linux/slab.h>
54 static unsigned char jazz_irq_bits[] = {
55 0, 0, 2, 3, 0, 1, 0, 4, 0, 2, 5, 0, 0, 0, 0, 6
58 static unsigned char jazz_dma_bits[] = {
59 0, 1, 0, 2, 0, 3, 0, 4
68 static int jazz16_base;
69 static unsigned char jazz16_bits;
76 #ifdef SMW_MIDI0001_INCLUDED
77 #include "smw-midi0001.h"
79 static unsigned char *smw_ucode;
80 static int smw_ucodeLen;
101 for (i = 0; i < 500000 && (limit-
jiffies)>0; i++)
117 for (i = 1000;
i; i--)
125 static void sb_intr (
sb_devc *devc)
128 unsigned char src = 0xff;
196 static void pci_intr(
sb_devc *devc)
210 switch (devc->
model) {
245 DDB(
printk(
"sb: No response to RESET\n"));
254 static void dsp_get_vers(
sb_devc * devc)
265 for (i = 100000;
i; i--)
269 if (devc->
major == 0)
278 spin_unlock_irqrestore(&devc->
lock, flags);
282 static int sb16_set_dma_hw(
sb_devc * devc)
286 if (devc->
dma8 != 0 && devc->
dma8 != 1 && devc->
dma8 != 3)
291 bits = (1 << devc->
dma8);
294 bits |= (1 << devc->
dma16);
305 unsigned char bits =
sb_getmixer(devc, 0x84) & ~0x06;
351 unsigned char bits = 0;
354 if (jazz16_base != 0 && jazz16_base != hw_config->
io_base)
371 bits = jazz16_bits = bits << 5;
372 jazz16_base = hw_config->
io_base;
381 spin_unlock_irqrestore(&jazz16_lock, flags);
401 if (hw_config->
irq < 1 || hw_config->
irq > 15 || jazz_irq_bits[hw_config->
irq] == 0)
406 if (hw_config->
dma < 0 || hw_config->
dma > 3 || jazz_dma_bits[hw_config->
dma] == 0)
411 if (hw_config->
dma2 < 0)
416 if (hw_config->
dma2 < 5 || hw_config->
dma2 > 7 || jazz_dma_bits[hw_config->
dma2] == 0)
427 (jazz_dma_bits[hw_config->
dma2] << 4)))
439 hw_config->
name =
"Jazz16";
444 static void relocate_ess1688(
sb_devc * devc)
466 DDB(
printk(
"Doing ESS1688 address selection\n"));
509 memset((
char *) &sb_info, 0,
sizeof(sb_info));
528 devc->
irq = hw_config->
irq;
549 printk(
"Yamaha PCI mode.\n");
568 spin_unlock_irqrestore(&devc->
lock, flags);
581 relocate_Jazz16(devc, hw_config);
584 relocate_ess1688(devc);
594 if (devc->
major == 0)
607 for (i = 0; i < 10000; i++)
620 printk(
"YMPCI selected\n");
630 if (detected_devc ==
NULL)
632 printk(
KERN_ERR "sb: Can't allocate memory for device information\n");
645 int mixer22, mixer30;
653 if (detected_devc ==
NULL)
658 devc = detected_devc;
659 detected_devc =
NULL;
683 if (
request_irq(hw_config->
irq, sbintr, i,
"soundblaster", devc) < 0)
691 if (devc->
major == 4)
692 if (!sb16_set_irq_hw(devc, devc->
irq))
705 devc->
type !=
MDL_SMW) || !init_Jazz16(devc, hw_config))
707 DDB(
printk(
"This is a genuine SB Pro\n"));
717 for (n = 0; n < 3 && devc->
irq_ok == 0; n++)
723 for (i = 0; !devc->
irq_ok && i < 10000; i++);
744 if (devc->
minor == 0)
751 switch (devc->
model) {
755 hw_config->
name =
"Sound Blaster Pro (8 BIT ONLY)";
783 hw_config->
name =
"Sound Blaster 16 (ALS-100)";
792 hw_config->
name =
"Sound Blaster 16 (ALS-007)";
797 hw_config->
name =
"Sound Blaster 16";
799 if (hw_config->
dma2 == -1)
801 else if (hw_config->
dma2 < 5 || hw_config->
dma2 > 7)
809 if(!sb16_set_dma_hw(devc)) {
826 hw_config->
name =
"Sound Blaster (8 BIT/MONO ONLY)";
842 printk(
KERN_INFO "This sound card may not be fully Sound Blaster Pro compatible.\n");
843 printk(
KERN_INFO "In many cases there is another way to configure OSS so that\n");
844 printk(
KERN_INFO "it works properly with OSS (for example in 16 bit mode).\n");
845 printk(
KERN_INFO "Please ignore this message if you _really_ have a SB Pro.\n");
850 printk(
KERN_INFO "several years old (8 bit only device) or alternatively the sound driver\n");
874 MDB(
printk(
"Sound Blaster: no audio devices found.\n"));
898 if (devc->
dma16 >= 0)
919 kfree(detected_devc);
945 spin_unlock_irqrestore(&devc->
lock, flags);
962 spin_unlock_irqrestore(&devc->
lock, flags);
973 value = (value & ~mask) | (val & mask);
981 static void smw_putmem(
sb_devc * devc,
int base,
int addr,
unsigned char val)
987 outb((addr & 0xff), base + 1);
988 outb((addr >> 8), base + 2);
991 spin_unlock_irqrestore(&jazz16_lock, flags);
994 static unsigned char smw_getmem(
sb_devc * devc,
int base,
int addr)
1001 outb((addr & 0xff), base + 1);
1002 outb((addr >> 8), base + 2);
1005 spin_unlock_irqrestore(&jazz16_lock, flags);
1011 int mpu_base = hw_config->
io_base;
1012 int mp_base = mpu_base + 4;
1021 control =
inb(mpu_base + 7);
1022 outb((control | 3), mpu_base + 7);
1023 outb(((control & 0xfe) | 2), mpu_base + 7);
1027 outb((control & 0xfc), mpu_base + 7);
1032 smw_putmem(devc, mp_base, 0, 0x00);
1033 smw_putmem(devc, mp_base, 1, 0xff);
1036 if (smw_getmem(devc, mp_base, 0) != 0x00 || smw_getmem(devc, mp_base, 1) != 0xff)
1038 DDB(
printk(
"SM Wave: No microcontroller RAM detected (%02x, %02x)\n", smw_getmem(devc, mp_base, 0), smw_getmem(devc, mp_base, 1)));
1051 smw_ucodeLen =
mod_firmware_load(
"/etc/sound/midi0001.bin", (
void *) &smw_ucode);
1055 if (smw_ucodeLen > 0)
1057 if (smw_ucodeLen != 8192)
1059 printk(
KERN_ERR "SM Wave: Invalid microcode (MIDI0001.BIN) length\n");
1066 for (i = 0; i < 8192; i++)
1067 smw_putmem(devc, mp_base, i, smw_ucode[i]);
1073 for (i = 0; i < 8192; i++)
1074 if (smw_getmem(devc, mp_base, i) != smw_ucode[i])
1091 static unsigned char scsi_irq_bits[] = {
1092 0, 0, 3, 1, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0
1094 control |= scsi_irq_bits[SMW_SCSI_IRQ] << 6;
1098 #ifdef SMW_OPL4_ENABLE
1109 outb((control | 0x03), mpu_base + 7);
1110 hw_config->
name =
"SoundMan Wave";
1116 int mpu_base = hw_config->
io_base;
1117 int sb_base = devc->
base;
1118 int irq = hw_config->
irq;
1120 unsigned char bits = 0;
1121 unsigned long flags;
1126 if (irq < 1 || irq > 15 ||
1127 jazz_irq_bits[irq] == 0)
1129 printk(
KERN_ERR "Jazz16: Invalid MIDI interrupt (IRQ%d)\n", irq);
1146 bits = jazz16_bits = bits << 5;
1169 spin_unlock_irqrestore(&jazz16_lock, flags);
1171 hw_config->
name =
"Jazz16";
1172 smw_midi_init(devc, hw_config);
1178 (jazz_dma_bits[devc->
dma16] << 4)))
1182 (jazz_irq_bits[irq] << 4)))
1193 if (last_devc ==
NULL)
1205 unsigned char bits =
sb_getmixer(devc, 0x84) & ~0x06;
1211 #if defined(CONFIG_SOUND_MPU401)
1224 hw_config->
name =
"ESS1xxx MPU";
1231 if (last_sb->
irq == -hw_config->
irq)
1233 (
void *)(
long) hw_config->
slots[1];
1238 switch (devc->
model)
1246 hw_config->
name =
"Sound Blaster 16";
1247 if (hw_config->
irq < 3 || hw_config->
irq == devc->
irq)
1248 hw_config->
irq = -devc->
irq;
1249 if (devc->
minor > 12)
1250 sb16_set_mpu_port(devc, hw_config);
1254 if (hw_config->
irq < 3 || hw_config->
irq == devc->
irq)
1255 hw_config->
irq = -devc->
irq;
1256 if (!init_Jazz16_midi(devc, hw_config))
1261 hw_config->
name =
"Yamaha PCI Legacy";
1262 printk(
"Yamaha PCI legacy UART401 check.\n");
1276 #if defined(CONFIG_SOUND_MPU401)
1277 if (!
strcmp (hw_config->
name,
"ESS1xxx MPU")) {