int probe_ss_ms_sound (struct address_info *hw_config) { int i, irq_bits = 0xff; if (devc->failed) return 0; if (devc->ok == 0) { printk ("SoundScape: Invalid initialization order.\n"); return 0; } for (i = 0; i < sizeof (valid_interrupts); i++) if (hw_config->irq == valid_interrupts[i]) { irq_bits = i; break; } if (hw_config->irq > 15 || irq_bits == 0xff) { printk ("SoundScape: Invalid MSS IRQ%d\n", hw_config->irq); return 0; } return ad1848_detect (hw_config->io_base, NULL, hw_config->osp); }
int probe_ss_ms_sound(struct address_info *hw_config) { int i, irq_bits = 0xff; int ad_flags = 0; if (devc->failed) { printk(KERN_ERR "soundscape: Card not detected\n"); return 0; } if (devc->ok == 0) { printk(KERN_ERR "soundscape: Invalid initialization order.\n"); return 0; } for (i = 0; i < sizeof(valid_interrupts); i++) { if (hw_config->irq == valid_interrupts[i]) { irq_bits = i; break; } } if (hw_config->irq > 15 || irq_bits == 0xff) { printk(KERN_ERR "soundscape: Invalid MSS IRQ%d\n", hw_config->irq); return 0; } if (old_hardware) ad_flags = 0x12345677; /* Tell that we may have a CS4248 chip (Spea-V7 Media FX) */ return ad1848_detect(hw_config->io_base, &ad_flags, hw_config->osp); }
int probe_sgalaxy( struct address_info *ai ) { if ( check_region( ai->io_base, 8 ) ) { printk(KERN_ERR "sgalaxy: WSS IO port 0x%03x not available\n", ai->io_base); return 0; } if ( ad1848_detect( ai->io_base+4, NULL, ai->osp ) ) return probe_ms_sound(ai); /* The card is already active, check irq etc... */ if ( check_region( ai->ai_sgbase, 0x10 ) ) { printk(KERN_ERR "sgalaxy: SB IO port 0x%03x not available\n", ai->ai_sgbase); return 0; } /* switch to MSS/WSS mode */ sb_rst( ai->ai_sgbase ); sb_cmd( ai->ai_sgbase, 9 ); sb_cmd( ai->ai_sgbase, 0 ); sleep( HZ/10 ); return probe_ms_sound(ai); }
static int wss_init(struct address_info *hw_config) { int ad_flags = 0; /* * Verify the WSS parameters */ if (check_region(hw_config->io_base, 8)) { printk(KERN_ERR "MSS: I/O port conflict\n"); return 0; } if (!ad1848_detect(hw_config->io_base + 4, &ad_flags, mad16_osp)) return 0; /* * Check if the IO port returns valid signature. The original MS Sound * system returns 0x04 while some cards (AudioTrix Pro for example) * return 0x00. */ if ((inb(hw_config->io_base + 3) & 0x3f) != 0x04 && (inb(hw_config->io_base + 3) & 0x3f) != 0x00) { DDB(printk("No MSS signature detected on port 0x%x (0x%x)\n", hw_config->io_base, inb(hw_config->io_base + 3))); return 0; } if (hw_config->irq > 11) { printk(KERN_ERR "MSS: Bad IRQ %d\n", hw_config->irq); return 0; } if (hw_config->dma != 0 && hw_config->dma != 1 && hw_config->dma != 3) { printk(KERN_ERR "MSS: Bad DMA %d\n", hw_config->dma); return 0; } /* * Check that DMA0 is not in use with a 8 bit board. */ if (hw_config->dma == 0 && inb(hw_config->io_base + 3) & 0x80) { printk("MSS: Can't use DMA0 with a 8 bit card/slot\n"); return 0; } if (hw_config->irq > 7 && hw_config->irq != 9 && inb(hw_config->io_base + 3) & 0x80) printk(KERN_ERR "MSS: Can't use IRQ%d with a 8 bit card/slot\n", hw_config->irq); return 1; }
int probe_trix_wss (struct address_info *hw_config) { /* * Check if the IO port returns valid signature. The original MS Sound * system returns 0x04 while some cards (AudioTriX Pro for example) * return 0x00. */ if (!trix_set_wss_port (hw_config)) return 0; if ((INB (hw_config->io_base + 3) & 0x3f) != 0x00) { DDB (printk ("No MSS signature detected on port 0x%x\n", hw_config->io_base)); return 0; } if (hw_config->irq > 11) { printk ("AudioTriX: Bad WSS IRQ %d\n", hw_config->irq); return 0; } if (hw_config->dma != 0 && hw_config->dma != 1 && hw_config->dma != 3) { printk ("AudioTriX: Bad WSS DMA %d\n", hw_config->dma); return 0; } /* * Check that DMA0 is not in use with a 8 bit board. */ if (hw_config->dma == 0 && INB (hw_config->io_base + 3) & 0x80) { printk ("AudioTriX: Can't use DMA0 with a 8 bit card\n"); return 0; } if (hw_config->irq > 7 && hw_config->irq != 9 && INB (hw_config->io_base + 3) & 0x80) { printk ("AudioTriX: Can't use IRQ%d with a 8 bit card\n", hw_config->irq); return 0; } return ad1848_detect (hw_config->io_base + 4); }
void attach_mad16(struct address_info *hw_config) { static char interrupt_bits[12] = { -1, -1, -1, -1, -1, -1, -1, 0x08, -1, 0x10, 0x18, 0x20 }; char bits; static char dma_bits[4] = { 1, 2, 0, 3 }; int config_port = hw_config->io_base + 0, version_port = hw_config->io_base + 3; int ad_flags = 0, dma = hw_config->dma, dma2 = hw_config->dma2; unsigned char dma2_bit = 0; already_initialized = 1; if (!ad1848_detect(hw_config->io_base + 4, &ad_flags, mad16_osp)) return; /* * Set the IRQ and DMA addresses. */ if (board_type == C930) interrupt_bits[5] = 0x28; /* Also IRQ5 is possible on C930 */ bits = interrupt_bits[hw_config->irq]; if (bits == -1) return; outb((bits | 0x40), config_port); if ((inb(version_port) & 0x40) == 0) printk(KERN_ERR "[IRQ Conflict?]\n"); /* * Handle the capture DMA channel */ if (ad_flags & AD_F_CS4231 && dma2 != -1 && dma2 != dma) { if (!((dma == 0 && dma2 == 1) || (dma == 1 && dma2 == 0) || (dma == 3 && dma2 == 0))) { /* Unsupported combination. Try to swap channels */ int tmp = dma; dma = dma2; dma2 = tmp; } if ((dma == 0 && dma2 == 1) || (dma == 1 && dma2 == 0) || (dma == 3 && dma2 == 0)) { dma2_bit = 0x04; /* Enable capture DMA */ } else { printk("MAD16: Invalid capture DMA\n"); dma2 = dma; } } else dma2 = dma; outb((bits | dma_bits[dma] | dma2_bit), config_port); /* Write IRQ+DMA setup */ hw_config->slots[0] = ad1848_init("MAD16 WSS", hw_config->io_base + 4, hw_config->irq, dma, dma2, 0, hw_config->osp); request_region(hw_config->io_base, 4, "MAD16 WSS config"); }
int probe_mad16(struct address_info *hw_config) { int i; static int valid_ports[] = { 0x530, 0xe80, 0xf40, 0x604 }; unsigned char tmp; unsigned char cs4231_mode = 0; int ad_flags = 0; if (already_initialized) return 0; mad16_osp = hw_config->osp; /* * Check that all ports return 0xff (bus float) when no password * is written to the password register. */ DDB(printk("--- Detecting MAD16 / Mozart ---\n")); if (!chip_detect()) return 0; if (board_type == C930) return init_c930(hw_config); for (i = 0xf8d; i <= 0xf93; i++) if (!c924pnp) DDB(printk("port %03x = %02x\n", i, mad_read(i))) else DDB(printk("port %03x = %02x\n", i-0x80, mad_read(i))); /* * Set the WSS address */ tmp = (mad_read(MC1_PORT) & 0x0f) | 0x80; /* Enable WSS, Disable SB */ for (i = 0; i < 5; i++) { if (i > 3) /* Not a valid port */ { printk(KERN_ERR "MAD16/Mozart: Bad WSS base address 0x%x\n", hw_config->io_base); return 0; } if (valid_ports[i] == hw_config->io_base) { tmp |= i << 4; /* WSS port select bits */ break; } } /* * Set optional CD-ROM and joystick settings. */ tmp &= ~0x0f; #if defined(MAD16_CONF) tmp |= ((MAD16_CONF) & 0x0f); /* CD-ROM and joystick bits */ #endif mad_write(MC1_PORT, tmp); #if defined(MAD16_CONF) && defined(MAD16_CDSEL) tmp = MAD16_CDSEL; #else tmp = mad_read(MC2_PORT); #endif #ifdef MAD16_OPL4 tmp |= 0x20; /* Enable OPL4 access */ #endif mad_write(MC2_PORT, tmp); mad_write(MC3_PORT, 0xf0); /* Disable SB */ if (board_type == C924) /* Specific C924 init values */ { mad_write(MC4_PORT, 0xA0); mad_write(MC5_PORT, 0x05); mad_write(MC6_PORT, 0x03); } if (!ad1848_detect(hw_config->io_base + 4, &ad_flags, mad16_osp)) return 0; if (ad_flags & (AD_F_CS4231 | AD_F_CS4248)) cs4231_mode = 0x02; /* CS4248/CS4231 sync delay switch */ if (board_type == C929) { mad_write(MC4_PORT, 0xa2); mad_write(MC5_PORT, 0xA5 | cs4231_mode); mad_write(MC6_PORT, 0x03); /* Disable MPU401 */ } else { mad_write(MC4_PORT, 0x02); mad_write(MC5_PORT, 0x30 | cs4231_mode); } for (i = 0xf8d; i <= 0xf93; i++) if (!c924pnp) DDB(printk("port %03x after init = %02x\n", i, mad_read(i))) else DDB(printk("port %03x after init = %02x\n", i-0x80, mad_read(i))); wss_init(hw_config); return 1; }
static int __init init_trix_wss(struct address_info *hw_config) { static unsigned char dma_bits[4] = { 1, 2, 0, 3 }; struct resource *ports; int config_port = hw_config->io_base + 0; int dma1 = hw_config->dma, dma2 = hw_config->dma2; int old_num_mixers = num_mixers; u8 config, bits; int ret; switch(hw_config->irq) { case 7: bits = 8; break; case 9: bits = 0x10; break; case 10: bits = 0x18; break; case 11: bits = 0x20; break; default: printk(KERN_ERR "AudioTrix: Bad WSS IRQ %d\n", hw_config->irq); return 0; } switch (dma1) { case 0: case 1: case 3: break; default: printk(KERN_ERR "AudioTrix: Bad WSS DMA %d\n", dma1); return 0; } switch (dma2) { case -1: case 0: case 1: case 3: break; default: printk(KERN_ERR "AudioTrix: Bad capture DMA %d\n", dma2); return 0; } /* * Check if the IO port returns valid signature. The original MS Sound * system returns 0x04 while some cards (AudioTrix Pro for example) * return 0x00. */ ports = request_region(hw_config->io_base + 4, 4, "ad1848"); if (!ports) { printk(KERN_ERR "AudioTrix: MSS I/O port conflict (%x)\n", hw_config->io_base); return 0; } if (!request_region(hw_config->io_base, 4, "MSS config")) { printk(KERN_ERR "AudioTrix: MSS I/O port conflict (%x)\n", hw_config->io_base); release_region(hw_config->io_base + 4, 4); return 0; } if (!trix_set_wss_port(hw_config)) goto fail; config = inb(hw_config->io_base + 3); if ((config & 0x3f) != 0x00) { MDB(printk(KERN_ERR "No MSS signature detected on port 0x%x\n", hw_config->io_base)); goto fail; } /* * Check that DMA0 is not in use with a 8 bit board. */ if (dma1 == 0 && config & 0x80) { printk(KERN_ERR "AudioTrix: Can't use DMA0 with a 8 bit card slot\n"); goto fail; } if (hw_config->irq > 9 && config & 0x80) { printk(KERN_ERR "AudioTrix: Can't use IRQ%d with a 8 bit card slot\n", hw_config->irq); goto fail; } ret = ad1848_detect(ports, NULL, hw_config->osp); if (!ret) goto fail; if (joystick==1) trix_write(0x15, 0x80); /* * Set the IRQ and DMA addresses. */ outb((bits | 0x40), config_port); if (dma2 == -1 || dma2 == dma1) { bits |= dma_bits[dma1]; dma2 = dma1; } else { unsigned char tmp; tmp = trix_read(0x13) & ~30; trix_write(0x13, tmp | 0x80 | (dma1 << 4)); tmp = trix_read(0x14) & ~30; trix_write(0x14, tmp | 0x80 | (dma2 << 4)); } outb((bits), config_port); /* Write IRQ+DMA setup */ hw_config->slots[0] = ad1848_init("AudioTrix Pro", ports, hw_config->irq, dma1, dma2, 0, hw_config->osp, THIS_MODULE); if (num_mixers > old_num_mixers) /* Mixer got installed */ { AD1848_REROUTE(SOUND_MIXER_LINE1, SOUND_MIXER_LINE); /* Line in */ AD1848_REROUTE(SOUND_MIXER_LINE2, SOUND_MIXER_CD); AD1848_REROUTE(SOUND_MIXER_LINE3, SOUND_MIXER_SYNTH); /* OPL4 */ AD1848_REROUTE(SOUND_MIXER_SPEAKER, SOUND_MIXER_ALTPCM); /* SB */ } return 1; fail: release_region(hw_config->io_base, 4); release_region(hw_config->io_base + 4, 4); return 0; }
static int __init init_ss_ms_sound(struct address_info *hw_config) { int i, irq_bits = 0xff; int ad_flags = 0; struct resource *ports; if (devc->failed) { printk(KERN_ERR "soundscape: Card not detected\n"); return 0; } if (devc->ok == 0) { printk(KERN_ERR "soundscape: Invalid initialization order.\n"); return 0; } for (i = 0; i < 4; i++) { if (hw_config->irq == valid_interrupts[i]) { irq_bits = i; break; } } if (irq_bits == 0xff) { printk(KERN_ERR "soundscape: Invalid MSS IRQ%d\n", hw_config->irq); return 0; } if (old_hardware) ad_flags = 0x12345677; /* Tell that we may have a CS4248 chip (Spea-V7 Media FX) */ else if (sscape_is_pnp) ad_flags = 0x87654321; /* Tell that we have a soundscape pnp with 1845 chip */ ports = request_region(hw_config->io_base, 4, "ad1848"); if (!ports) { printk(KERN_ERR "soundscape: ports busy\n"); return 0; } if (!ad1848_detect(ports, &ad_flags, hw_config->osp)) { release_region(hw_config->io_base, 4); return 0; } if (!sscape_is_pnp) /*pnp is already setup*/ { /* * Setup the DMA polarity. */ sscape_write(devc, GA_DMACFG_REG, 0x50); /* * Take the gate-array off of the DMA channel. */ sscape_write(devc, GA_DMAB_REG, 0x20); /* * Init the AD1848 (CD-ROM) config reg. */ sscape_write(devc, GA_CDCFG_REG, 0x89 | (hw_config->dma << 4) | (irq_bits << 1)); } if (hw_config->irq == devc->irq) printk(KERN_WARNING "soundscape: Warning! The WSS mode can't share IRQ with MIDI\n"); hw_config->slots[0] = ad1848_init( sscape_is_pnp ? "SoundScape" : "SoundScape PNP", ports, hw_config->irq, hw_config->dma, hw_config->dma, 0, devc->osp, THIS_MODULE); if (hw_config->slots[0] != -1) /* The AD1848 driver installed itself */ { audio_devs[hw_config->slots[0]]->coproc = &sscape_coproc_operations; devc->codec_audiodev = hw_config->slots[0]; devc->my_audiodev = hw_config->slots[0]; /* Set proper routings here (what are they) */ AD1848_REROUTE(SOUND_MIXER_LINE1, SOUND_MIXER_LINE); } #ifdef SSCAPE_DEBUG5 /* * Temporary debugging aid. Print contents of the registers * after the AD1848 device has been initialized. */ { int i; for (i = 0; i < 13; i++) printk("I%d = %02x\n", i, sscape_read(devc, i)); } #endif return 1; }
int probe_gus_db16 (struct address_info *hw_config) { return ad1848_detect (hw_config->io_base, NULL, hw_config->osp); }