⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prodigy192.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
			   SNDRV_CTL_ELEM_ACCESS_TLV_READ),		.name = "Master Playback Volume",		.info = stac9460_dac_vol_info,		.get = stac9460_dac_vol_get,		.put = stac9460_dac_vol_put,		.private_value = 1,		.tlv = { .p = db_scale_dac }	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "DAC Switch",		.count = 6,		.info = stac9460_dac_mute_info,		.get = stac9460_dac_mute_get,		.put = stac9460_dac_mute_put,	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |			   SNDRV_CTL_ELEM_ACCESS_TLV_READ),		.name = "DAC Volume",		.count = 6,		.info = stac9460_dac_vol_info,		.get = stac9460_dac_vol_get,		.put = stac9460_dac_vol_put,		.tlv = { .p = db_scale_dac }	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "ADC Capture Switch",		.count = 1,		.info = stac9460_adc_mute_info,		.get = stac9460_adc_mute_get,		.put = stac9460_adc_mute_put,	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |			   SNDRV_CTL_ELEM_ACCESS_TLV_READ),		.name = "ADC Capture Volume",		.count = 1,		.info = stac9460_adc_vol_info,		.get = stac9460_adc_vol_get,		.put = stac9460_adc_vol_put,		.tlv = { .p = db_scale_adc }	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Analog Capture Input",		.info = stac9460_mic_sw_info,		.get = stac9460_mic_sw_get,		.put = stac9460_mic_sw_put,	},#if 0	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Capture Route",		.info = wm_adc_mux_info,		.get = wm_adc_mux_get,		.put = wm_adc_mux_put,	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Headphone Amplifier Switch",		.info = aureon_bool_info,		.get = aureon_hpamp_get,		.put = aureon_hpamp_put	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "DAC Deemphasis Switch",		.info = aureon_bool_info,		.get = aureon_deemp_get,		.put = aureon_deemp_put	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "ADC Oversampling",		.info = aureon_oversampling_info,		.get = aureon_oversampling_get,		.put = aureon_oversampling_put	},#endif};/* AK4114 - ICE1724 connections on Prodigy192 + MI/ODI/O *//* CDTO (pin 32) -- GPIO11 pin 86 * CDTI (pin 33) -- GPIO10 pin 77 * CCLK (pin 34) -- GPIO9 pin 76 * CSN  (pin 35) -- GPIO8 pin 75 */#define AK4114_ADDR	0x00 /* C1-C0: Chip Address			      * (According to datasheet fixed to “00”)			      *//* * 4wire ak4114 protocol - writing data */static void write_data(struct snd_ice1712 *ice, unsigned int gpio,		       unsigned int data, int idx){	for (; idx >= 0; idx--) {		/* drop clock */		gpio &= ~VT1724_PRODIGY192_CCLK;		snd_ice1712_gpio_write(ice, gpio);		udelay(1);		/* set data */		if (data & (1 << idx))			gpio |= VT1724_PRODIGY192_CDOUT;		else			gpio &= ~VT1724_PRODIGY192_CDOUT;		snd_ice1712_gpio_write(ice, gpio);		udelay(1);		/* raise clock */		gpio |= VT1724_PRODIGY192_CCLK;		snd_ice1712_gpio_write(ice, gpio);		udelay(1);	}}/* * 4wire ak4114 protocol - reading data */static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,			       int idx){	unsigned char data = 0;	for (; idx >= 0; idx--) {		/* drop clock */		gpio &= ~VT1724_PRODIGY192_CCLK;		snd_ice1712_gpio_write(ice, gpio);		udelay(1);		/* read data */		if (snd_ice1712_gpio_read(ice) & VT1724_PRODIGY192_CDIN)			data |= (1 << idx);		udelay(1);		/* raise clock */		gpio |= VT1724_PRODIGY192_CCLK;		snd_ice1712_gpio_write(ice, gpio);		udelay(1);	}	return data;}/* * 4wire ak4114 protocol - starting sequence */static unsigned int prodigy192_4wire_start(struct snd_ice1712 *ice){	unsigned int tmp;	snd_ice1712_save_gpio_status(ice);	tmp = snd_ice1712_gpio_read(ice);	tmp |= VT1724_PRODIGY192_CCLK; /* high at init */	tmp &= ~VT1724_PRODIGY192_CS; /* drop chip select */	snd_ice1712_gpio_write(ice, tmp);	udelay(1);	return tmp;}/* * 4wire ak4114 protocol - final sequence */static void prodigy192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp){	tmp |= VT1724_PRODIGY192_CS; /* raise chip select */	snd_ice1712_gpio_write(ice, tmp);	udelay(1);	snd_ice1712_restore_gpio_status(ice);}/* * Write data to addr register of ak4114 */static void prodigy192_ak4114_write(void *private_data, unsigned char addr,			       unsigned char data){	struct snd_ice1712 *ice = private_data;	unsigned int tmp, addrdata;	tmp = prodigy192_4wire_start(ice);	addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);	addrdata = (addrdata << 8) | data;	write_data(ice, tmp, addrdata, 15);	prodigy192_4wire_finish(ice, tmp);}/* * Read data from addr register of ak4114 */static unsigned char prodigy192_ak4114_read(void *private_data,					    unsigned char addr){	struct snd_ice1712 *ice = private_data;	unsigned int tmp;	unsigned char data;	tmp = prodigy192_4wire_start(ice);	write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7);	data = read_data(ice, tmp, 7);	prodigy192_4wire_finish(ice, tmp);	return data;}static int ak4114_input_sw_info(struct snd_kcontrol *kcontrol,	       			struct snd_ctl_elem_info *uinfo){	static char *texts[2] = { "Toslink", "Coax" };	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;	uinfo->count = 1;	uinfo->value.enumerated.items = 2;	if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)		uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);        return 0;}static int ak4114_input_sw_get(struct snd_kcontrol *kcontrol,	       		struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	unsigned char val;			val = prodigy192_ak4114_read(ice, AK4114_REG_IO1);	/* AK4114_IPS0 bit = 0 -> RX0 = Toslink	 * AK4114_IPS0 bit = 1 -> RX1 = Coax	 */	ucontrol->value.enumerated.item[0] = (val & AK4114_IPS0) ? 1 : 0;	return 0;}static int ak4114_input_sw_put(struct snd_kcontrol *kcontrol,	       		struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	unsigned char new, old, itemvalue;	int change;	old = prodigy192_ak4114_read(ice, AK4114_REG_IO1);	/* AK4114_IPS0 could be any bit */	itemvalue = (ucontrol->value.enumerated.item[0]) ? 0xff : 0x00;	new = (itemvalue & AK4114_IPS0) | (old & ~AK4114_IPS0);	change = (new != old);	if (change)		prodigy192_ak4114_write(ice, AK4114_REG_IO1, new);	return change;}static struct snd_kcontrol_new ak4114_controls[] __devinitdata = {	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "MIODIO IEC958 Capture Input",		.info = ak4114_input_sw_info,		.get = ak4114_input_sw_get,		.put = ak4114_input_sw_put,	}};static int prodigy192_ak4114_init(struct snd_ice1712 *ice){	static const unsigned char ak4114_init_vals[] = {		AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,		/* ice1724 expects I2S and provides clock,		 * DEM0 disables the deemphasis filter		 */		AK4114_DIF_I24I2S | AK4114_DEM0 ,		AK4114_TX1E,		AK4114_EFH_1024 | AK4114_DIT, /* default input RX0 */		0,		0	};	static const unsigned char ak4114_init_txcsb[] = {		0x41, 0x02, 0x2c, 0x00, 0x00	};	return snd_ak4114_create(ice->card,				 prodigy192_ak4114_read,				 prodigy192_ak4114_write,				 ak4114_init_vals, ak4114_init_txcsb,				 ice, &ice->spec.prodigy192.ak4114);}static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice){	unsigned int i;	int err;	for (i = 0; i < ARRAY_SIZE(stac_controls); i++) {		err = snd_ctl_add(ice->card,				  snd_ctl_new1(&stac_controls[i], ice));		if (err < 0)			return err;	}	if (ice->spec.prodigy192.ak4114) {		/* ak4114 is connected */		for (i = 0; i < ARRAY_SIZE(ak4114_controls); i++) {			err = snd_ctl_add(ice->card,					  snd_ctl_new1(&ak4114_controls[i],						       ice));			if (err < 0)				return err;		}		err = snd_ak4114_build(ice->spec.prodigy192.ak4114,				NULL, /* ak4114 in MIO/DI/O handles no IEC958 output */				ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);		if (err < 0)			return err;	}	return 0;}/* * check for presence of MI/ODI/O add-on card with digital inputs */static int prodigy192_miodio_exists(struct snd_ice1712 *ice){	unsigned char orig_value;	const unsigned char test_data = 0xd1;	/* random value */	unsigned char addr = AK4114_REG_INT0_MASK; /* random SAFE address */	int exists = 0;	orig_value = prodigy192_ak4114_read(ice, addr);	prodigy192_ak4114_write(ice, addr, test_data);	if (prodigy192_ak4114_read(ice, addr) == test_data) {		/* ak4114 seems to communicate, apparently exists */		/* writing back original value */		prodigy192_ak4114_write(ice, addr, orig_value);		exists = 1;	}	return exists;}/* * initialize the chip */static int __devinit prodigy192_init(struct snd_ice1712 *ice){	static const unsigned short stac_inits_prodigy[] = {		STAC946X_RESET, 0,/*		STAC946X_MASTER_VOLUME, 0,		STAC946X_LF_VOLUME, 0,		STAC946X_RF_VOLUME, 0,		STAC946X_LR_VOLUME, 0,		STAC946X_RR_VOLUME, 0,		STAC946X_CENTER_VOLUME, 0,		STAC946X_LFE_VOLUME, 0,*/		(unsigned short)-1	};	const unsigned short *p;	int err = 0;	/* prodigy 192 */	ice->num_total_dacs = 6;	ice->num_total_adcs = 2;	ice->vt1720 = 0;  /* ice1724, e.g. 23 GPIOs */		/* initialize codec */	p = stac_inits_prodigy;	for (; *p != (unsigned short)-1; p += 2)		stac9460_put(ice, p[0], p[1]);	/* MI/ODI/O add on card with AK4114 */	if (prodigy192_miodio_exists(ice)) {		err = prodigy192_ak4114_init(ice);		/* from this moment if err = 0 then		 * ice->spec.prodigy192.ak4114 should not be null		 */		snd_printdd("AK4114 initialized with status %d\n", err);	} else		snd_printdd("AK4114 not found\n");	if (err < 0)		return err;	return 0;}/* * Aureon boards don't provide the EEPROM data except for the vendor IDs. * hence the driver needs to sets up it properly. */static unsigned char prodigy71_eeprom[] __devinitdata = {	[ICE_EEP2_SYSCONF]     = 0x6a,	/* 49MHz crystal, mpu401,					 * spdif-in+ 1 stereo ADC,					 * 3 stereo DACs					 */	[ICE_EEP2_ACLINK]      = 0x80,	/* I2S */	[ICE_EEP2_I2S]         = 0xf8,	/* vol, 96k, 24bit, 192k */	[ICE_EEP2_SPDIF]       = 0xc3,	/* out-en, out-int, spdif-in */	[ICE_EEP2_GPIO_DIR]    = 0xff,	[ICE_EEP2_GPIO_DIR1]   = ~(VT1724_PRODIGY192_CDIN >> 8) ,	[ICE_EEP2_GPIO_DIR2]   = 0xbf,	[ICE_EEP2_GPIO_MASK]   = 0x00,	[ICE_EEP2_GPIO_MASK1]  = 0x00,	[ICE_EEP2_GPIO_MASK2]  = 0x00,	[ICE_EEP2_GPIO_STATE]  = 0x00,	[ICE_EEP2_GPIO_STATE1] = 0x00,	[ICE_EEP2_GPIO_STATE2] = 0x10,  /* GPIO20: 0 = CD drive dig. input					 * passthrough,					 * 1 = SPDIF-OUT from ice1724					 */};/* entry point */struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {	{		.subvendor = VT1724_SUBDEVICE_PRODIGY192VE,		.name = "Audiotrak Prodigy 192",		.model = "prodigy192",		.chip_init = prodigy192_init,		.build_controls = prodigy192_add_controls,		.eeprom_size = sizeof(prodigy71_eeprom),		.eeprom_data = prodigy71_eeprom,	},	{ } /* terminator */};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -