sound/isa/sb/jazz16.c

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

File Facts

System
Linux kernel
Corpus path
sound/isa/sb/jazz16.c
Extension
.c
Size
9917 bytes
Lines
368
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_card_jazz16 {
	struct snd_sb *chip;
};

static irqreturn_t jazz16_interrupt(int irq, void *chip)
{
	return snd_sb8dsp_interrupt(chip);
}

static int jazz16_configure_ports(struct snd_card *card,
				  unsigned long port,
				  unsigned long mpu_port, int idx)
{
	unsigned char val;

	if (!request_region(0x201, 1, "jazz16 config")) {
		dev_err(card->dev, "config port region is already in use.\n");
		return -EBUSY;
	}
	outb(SB_JAZZ16_WAKEUP - idx, 0x201);
	udelay(100);
	outb(SB_JAZZ16_SET_PORTS + idx, 0x201);
	udelay(100);
	val = port & 0x70;
	val |= (mpu_port & 0x30) >> 4;
	outb(val, 0x201);

	release_region(0x201, 1);
	return 0;
}

static int jazz16_detect_board(struct snd_card *card, unsigned long port,
			       unsigned long mpu_port)
{
	int err;
	int val;
	struct snd_sb chip = {};

	if (!request_region(port, 0x10, "jazz16")) {
		dev_err(card->dev, "I/O port region is already in use.\n");
		return -EBUSY;
	}
	/* just to call snd_sbdsp_command/reset/get_byte() */
	chip.port = port;

	err = snd_sbdsp_reset(&chip);
	if (err < 0)
		for (val = 0; val < 4; val++) {
			err = jazz16_configure_ports(card, port, mpu_port, val);
			if (err < 0)
				break;

			err = snd_sbdsp_reset(&chip);
			if (!err)
				break;
		}
	if (err < 0) {
		err = -ENODEV;
		goto err_unmap;
	}
	if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_BRD_REV)) {
		err = -EBUSY;
		goto err_unmap;
	}
	val = snd_sbdsp_get_byte(&chip);
	if (val >= 0x30)
		snd_sbdsp_get_byte(&chip);

	if ((val & 0xf0) != 0x10) {
		err = -ENODEV;
		goto err_unmap;
	}
	if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_MODEL)) {
		err = -EBUSY;
		goto err_unmap;
	}
	snd_sbdsp_get_byte(&chip);
	err = snd_sbdsp_get_byte(&chip);
	dev_dbg(card->dev, "Media Vision Jazz16 board detected: rev 0x%x, model 0x%x\n",
		val, err);

	err = 0;

err_unmap:
	release_region(port, 0x10);
	return err;
}

static int jazz16_configure_board(struct snd_sb *chip, int mpu_irq)
{

Annotation

Implementation Notes