sound/ppc/awacs.c

Source file repositories/reference/linux-study-clean/sound/ppc/awacs.c

File Facts

System
Linux kernel
Corpus path
sound/ppc/awacs.c
Extension
.c
Size
31633 bytes
Lines
1124
Domain
Driver Families
Bucket
sound/ppc
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 awacs_amp {
	unsigned char amp_master;
	unsigned char amp_vol[2][2];
	unsigned char amp_tone[2];
};

#define CHECK_CUDA_AMP() (sys_ctrler == SYS_CTRLER_CUDA)

#endif /* PMAC_AMP_AVAIL */


static void snd_pmac_screamer_wait(struct snd_pmac *chip)
{
	long timeout = 2000;
	while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) {
		mdelay(1);
		if (! --timeout) {
			dev_dbg(chip->card->dev, "%s timeout\n", __func__);
			break;
		}
	}
}

/*
 * write AWACS register
 */
static void
snd_pmac_awacs_write(struct snd_pmac *chip, int val)
{
	long timeout = 5000000;

	if (chip->model == PMAC_SCREAMER)
		snd_pmac_screamer_wait(chip);
	out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22));
	while (in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) {
		if (! --timeout) {
			dev_dbg(chip->card->dev, "%s timeout\n", __func__);
			break;
		}
	}
}

static void
snd_pmac_awacs_write_reg(struct snd_pmac *chip, int reg, int val)
{
	snd_pmac_awacs_write(chip, val | (reg << 12));
	chip->awacs_reg[reg] = val;
}

static void
snd_pmac_awacs_write_noreg(struct snd_pmac *chip, int reg, int val)
{
	snd_pmac_awacs_write(chip, val | (reg << 12));
}

#ifdef CONFIG_PM
/* Recalibrate chip */
static void screamer_recalibrate(struct snd_pmac *chip)
{
	if (chip->model != PMAC_SCREAMER)
		return;

	/* Sorry for the horrible delays... I hope to get that improved
	 * by making the whole PM process asynchronous in a future version
	 */
	snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
	if (chip->manufacturer == 0x1)
		/* delay for broken crystal part */
		msleep(750);
	snd_pmac_awacs_write_noreg(chip, 1,
				   chip->awacs_reg[1] | MASK_RECALIBRATE |
				   MASK_CMUTE | MASK_AMUTE);
	snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]);
	snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]);
}

#else
#define screamer_recalibrate(chip) /* NOP */
#endif


/*
 * additional callback to set the pcm format
 */
static void snd_pmac_awacs_set_format(struct snd_pmac *chip)
{
	chip->awacs_reg[1] &= ~MASK_SAMPLERATE;
	chip->awacs_reg[1] |= chip->rate_index << 3;
	snd_pmac_awacs_write_reg(chip, 1, chip->awacs_reg[1]);
}

Annotation

Implementation Notes