From: brodskye at cae.wisc.edu Newsgroups: alt.sb.programmer Subject: Re: Need help on (auto)detecting SB References: <33b48f6a.2991144@news.pi.net> Reply-To: ebrodsky@pobox.com Organization: Capital Sound Programming In article <33b48f6a.2991144@news.pi.net>, wrote: >Could someone plz point me to some sources on how to detect the >presence of a soundblaster card? I also would like to autodetect >address, irq and dma if that's possible. for source, look around the ftp site x2ftp.oulu.fi. I believe there are a couple of SB detection programs available there. Autodetecting the address is the easiest. You iterate through each address though, attempting to reset the card. If it is successful, then you've found it; if not, try another. Detecting the IRQ is a bit harder. The usual way to do this is to install a handler on each IRQ supported by a sound card, then trigger an interrupt, detecting which handler is called. There are two ways to trigger an interrupt. The easiest is to write DSP command 0xF2. However, this is undocumented and may not work on all sound cards. A more reliable method would be to run a short DMA transfer, but this requires using a DMA channel. Detecting the DMA channel is the most difficult. The only way I've found to do this is to program a transfer and see what channel it goes on. I've never tried this myself, so I have several theories on how to detect the channel. One is to program the transfer with the DSP, then examine the DRQ register to see whether which channel has a request. If this doesn't work, you can program each channel in turn until it works. If you're using a SB16, you can read the IRQ and DMA channel from a register in the mixer, making detection only a matter of finding the base address. I've never written any detection code myself, although I've looked at the source code for a few and disassembled one, though none supported DMA. I have seen a program that detects DMA though, so I know it's possible. If I find some time, maybe I'll write some code to detect sound card. I've been suggesting these techniques for years without ever having tried them myself. Ethan Brodsky