sound/ppc/tumbler.c

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

File Facts

System
Linux kernel
Corpus path
sound/ppc/tumbler.c
Extension
.c
Size
38551 bytes
Lines
1498
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 pmac_gpio {
	unsigned int addr;
	u8 active_val;
	u8 inactive_val;
	u8 active_state;
};

struct pmac_tumbler {
	struct pmac_keywest i2c;
	struct pmac_gpio audio_reset;
	struct pmac_gpio amp_mute;
	struct pmac_gpio line_mute;
	struct pmac_gpio line_detect;
	struct pmac_gpio hp_mute;
	struct pmac_gpio hp_detect;
	int headphone_irq;
	int lineout_irq;
	unsigned int save_master_vol[2];
	unsigned int master_vol[2];
	unsigned int save_master_switch[2];
	unsigned int master_switch[2];
	unsigned int mono_vol[VOL_IDX_LAST_MONO];
	unsigned int mix_vol[VOL_IDX_LAST_MIX][2]; /* stereo volumes for tas3004 */
	int drc_range;
	int drc_enable;
	int capture_source;
	int anded_reset;
	int auto_mute_notify;
	int reset_on_sleep;
	u8  acs;
};


/*
 */

static int send_init_client(struct pmac_keywest *i2c, const unsigned int *regs)
{
	while (*regs > 0) {
		int err, count = 10;
		do {
			err = i2c_smbus_write_byte_data(i2c->client,
							regs[0], regs[1]);
			if (err >= 0)
				break;
			DBG("(W) i2c error %d\n", err);
			mdelay(10);
		} while (count--);
		if (err < 0)
			return -ENXIO;
		regs += 2;
	}
	return 0;
}


static int tumbler_init_client(struct pmac_keywest *i2c)
{
	static const unsigned int regs[] = {
		/* normal operation, SCLK=64fps, i2s output, i2s input, 16bit width */
		TAS_REG_MCS, (1<<6)|(2<<4)|(2<<2)|0,
		0, /* terminator */
	};
	DBG("(I) tumbler init client\n");
	return send_init_client(i2c, regs);
}

static int snapper_init_client(struct pmac_keywest *i2c)
{
	static const unsigned int regs[] = {
		/* normal operation, SCLK=64fps, i2s output, 16bit width */
		TAS_REG_MCS, (1<<6)|(2<<4)|0,
		/* normal operation, all-pass mode */
		TAS_REG_MCS2, (1<<1),
		/* normal output, no deemphasis, A input, power-up, line-in */
		TAS_REG_ACS, 0,
		0, /* terminator */
	};
	DBG("(I) snapper init client\n");
	return send_init_client(i2c, regs);
}
	
/*
 * gpio access
 */
#define do_gpio_write(gp, val) \
	pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, (gp)->addr, val)
#define do_gpio_read(gp) \
	pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, (gp)->addr, 0)
#define tumbler_gpio_free(gp) /* NOP */

Annotation

Implementation Notes