sound/pci/echoaudio/echoaudio_dsp.c

Source file repositories/reference/linux-study-clean/sound/pci/echoaudio/echoaudio_dsp.c

File Facts

System
Linux kernel
Corpus path
sound/pci/echoaudio/echoaudio_dsp.c
Extension
.c
Size
30037 bytes
Lines
1142
Domain
Driver Families
Bucket
sound/pci
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

if (chip->comm_page->handshake) {
			return 0;
		}
		udelay(1);
	}

	dev_err(chip->card->dev, "wait_handshake(): Timeout waiting for DSP\n");
	return -EBUSY;
}



/* Much of the interaction between the DSP and the driver is done via vector
commands; send_vector writes a vector command to the DSP.  Typically, this
causes the DSP to read or write fields in the comm page.
PCI posting is not required thanks to the handshake logic. */
static int send_vector(struct echoaudio *chip, u32 command)
{
	int i;

	wmb();	/* Flush all pending writes before sending the command */

	/* Wait up to 100ms for the "vector busy" bit to be off */
	for (i = 0; i < VECTOR_BUSY_TIMEOUT; i++) {
		if (!(get_dsp_register(chip, CHI32_VECTOR_REG) &
		      CHI32_VECTOR_BUSY)) {
			set_dsp_register(chip, CHI32_VECTOR_REG, command);
			/*if (i)  DE_ACT(("send_vector time: %d\n", i));*/
			return 0;
		}
		udelay(1);
	}

	dev_err(chip->card->dev, "timeout on send_vector\n");
	return -EBUSY;
}



/* write_dsp writes a 32-bit value to the DSP; this is used almost
exclusively for loading the DSP. */
static int write_dsp(struct echoaudio *chip, u32 data)
{
	u32 status, i;

	for (i = 0; i < 10000000; i++) {	/* timeout = 10s */
		status = get_dsp_register(chip, CHI32_STATUS_REG);
		if ((status & CHI32_STATUS_HOST_WRITE_EMPTY) != 0) {
			set_dsp_register(chip, CHI32_DATA_REG, data);
			wmb();			/* write it immediately */
			return 0;
		}
		udelay(1);
		cond_resched();
	}

	chip->bad_board = true;		/* Set true until DSP re-loaded */
	dev_dbg(chip->card->dev, "write_dsp: Set bad_board to true\n");
	return -EIO;
}



/* read_dsp reads a 32-bit value from the DSP; this is used almost
exclusively for loading the DSP and checking the status of the ASIC. */
static int read_dsp(struct echoaudio *chip, u32 *data)
{
	u32 status, i;

	for (i = 0; i < READ_DSP_TIMEOUT; i++) {
		status = get_dsp_register(chip, CHI32_STATUS_REG);
		if ((status & CHI32_STATUS_HOST_READ_FULL) != 0) {
			*data = get_dsp_register(chip, CHI32_DATA_REG);
			return 0;
		}
		udelay(1);
		cond_resched();
	}

	chip->bad_board = true;		/* Set true until DSP re-loaded */
	dev_err(chip->card->dev, "read_dsp: Set bad_board to true\n");
	return -EIO;
}



/****************************************************************************
	Firmware loading functions
 ****************************************************************************/

Annotation

Implementation Notes