sound/isa/sb/sb8.c

Source file repositories/reference/linux-study-clean/sound/isa/sb/sb8.c

File Facts

System
Linux kernel
Corpus path
sound/isa/sb/sb8.c
Extension
.c
Size
5812 bytes
Lines
222
Domain
Driver Families
Bucket
sound/isa
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct snd_sb8 {
	struct resource *fm_res;	/* used to block FM i/o region for legacy cards */
	struct snd_sb *chip;
};

static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id)
{
	struct snd_sb *chip = dev_id;

	if (chip->open & SB_OPEN_PCM) {
		return snd_sb8dsp_interrupt(chip);
	} else {
		return snd_sb8dsp_midi_interrupt(chip);
	}
}

static int snd_sb8_match(struct device *pdev, unsigned int dev)
{
	if (!enable[dev])
		return 0;
	if (irq[dev] == SNDRV_AUTO_IRQ) {
		dev_err(pdev, "please specify irq\n");
		return 0;
	}
	if (dma8[dev] == SNDRV_AUTO_DMA) {
		dev_err(pdev, "please specify dma8\n");
		return 0;
	}
	return 1;
}

static int snd_sb8_probe(struct device *pdev, unsigned int dev)
{
	struct snd_sb *chip;
	struct snd_card *card;
	struct snd_sb8 *acard;
	struct snd_opl3 *opl3;
	int err;

	err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE,
				sizeof(struct snd_sb8), &card);
	if (err < 0)
		return err;
	acard = card->private_data;

	/*
	 * Block the 0x388 port to avoid PnP conflicts.
	 * No need to check this value after request_region,
	 * as we never do anything with it.
	 */
	acard->fm_res = devm_request_region(card->dev, 0x388, 4,
					    "SoundBlaster FM");

	if (port[dev] != SNDRV_AUTO_PORT) {
		err = snd_sbdsp_create(card, port[dev], irq[dev],
				       snd_sb8_interrupt, dma8[dev],
				       -1, SB_HW_AUTO, &chip);
		if (err < 0)
			return err;
	} else {
		/* auto-probe legacy ports */
		static const unsigned long possible_ports[] = {
			0x220, 0x240, 0x260,
		};
		int i;
		for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
			err = snd_sbdsp_create(card, possible_ports[i],
					       irq[dev],
					       snd_sb8_interrupt,
					       dma8[dev],
					       -1,
					       SB_HW_AUTO,
					       &chip);
			if (err >= 0) {
				port[dev] = possible_ports[i];
				break;
			}
		}
		if (i >= ARRAY_SIZE(possible_ports))
			return -EINVAL;
	}
	acard->chip = chip;
			
	if (chip->hardware >= SB_HW_16) {
		if (chip->hardware == SB_HW_ALS100)
			dev_warn(pdev, "ALS100 chip detected at 0x%lx, try snd-als100 module\n",
				 port[dev]);
		else
			dev_warn(pdev, "SB 16 chip detected at 0x%lx, try snd-sb16 module\n",
				 port[dev]);

Annotation

Implementation Notes