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

📄 ews.c

📁 LINUX 2.6.17.4的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
	.cif = 1, /* CIF high */	.data_mask = ICE1712_EWS88_SERIAL_DATA,	.clk_mask = ICE1712_EWS88_SERIAL_CLOCK,	.cs_mask = 0,	.cs_addr = 0,	.cs_none = 0, /* no chip select on gpio */	.add_flags = ICE1712_EWS88_RW, /* set rw bit high */	.mask_flags = 0,};static struct snd_akm4xxx akm_ewx2496 __devinitdata = {	.num_adcs = 2,	.num_dacs = 2,	.type = SND_AK4524,	.ops = {		.lock = ewx2496_ak4524_lock	}};static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {	.caddr = 2,	.cif = 1, /* CIF high */	.data_mask = ICE1712_EWS88_SERIAL_DATA,	.clk_mask = ICE1712_EWS88_SERIAL_CLOCK,	.cs_mask = ICE1712_EWX2496_AK4524_CS,	.cs_addr = ICE1712_EWX2496_AK4524_CS,	.cs_none = 0,	.add_flags = ICE1712_EWS88_RW, /* set rw bit high */	.mask_flags = 0,};static struct snd_akm4xxx akm_6fire __devinitdata = {	.num_adcs = 6,	.num_dacs = 6,	.type = SND_AK4524,	.ops = {		.lock = dmx6fire_ak4524_lock	}};static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = {	.caddr = 2,	.cif = 1, /* CIF high */	.data_mask = ICE1712_6FIRE_SERIAL_DATA,	.clk_mask = ICE1712_6FIRE_SERIAL_CLOCK,	.cs_mask = 0,	.cs_addr = 0, /* set later */	.cs_none = 0,	.add_flags = ICE1712_6FIRE_RW, /* set rw bit high */	.mask_flags = 0,};/* * initialize the chip *//* 6fire specific */#define PCF9554_REG_INPUT      0#define PCF9554_REG_OUTPUT     1#define PCF9554_REG_POLARITY   2#define PCF9554_REG_CONFIG     3static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data);static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice){	int err;	struct snd_akm4xxx *ak;	/* set the analog DACs */	switch (ice->eeprom.subvendor) {	case ICE1712_SUBDEVICE_EWX2496:		ice->num_total_dacs = 2;		ice->num_total_adcs = 2;		break;		case ICE1712_SUBDEVICE_EWS88MT:	case ICE1712_SUBDEVICE_EWS88MT_NEW:	case ICE1712_SUBDEVICE_PHASE88:		ice->num_total_dacs = 8;		ice->num_total_adcs = 8;		break;	case ICE1712_SUBDEVICE_EWS88D:		/* Note: not analog but ADAT I/O */		ice->num_total_dacs = 8;		ice->num_total_adcs = 8;		break;	case ICE1712_SUBDEVICE_DMX6FIRE:		ice->num_total_dacs = 6;		ice->num_total_adcs = 6;		break;	}	/* create i2c */	if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {		snd_printk(KERN_ERR "unable to create I2C bus\n");		return err;	}	ice->i2c->private_data = ice;	ice->i2c->hw_ops.bit = &snd_ice1712_ewx_cs8427_bit_ops;	/* create i2c devices */	switch (ice->eeprom.subvendor) {	case ICE1712_SUBDEVICE_DMX6FIRE:		if ((err = snd_i2c_device_create(ice->i2c, "PCF9554", ICE1712_6FIRE_PCF9554_ADDR, &ice->spec.i2cdevs[EWS_I2C_6FIRE])) < 0) {			snd_printk(KERN_ERR "PCF9554 initialization failed\n");			return err;		}		snd_ice1712_6fire_write_pca(ice, PCF9554_REG_CONFIG, 0x80);		break;	case ICE1712_SUBDEVICE_EWS88MT:	case ICE1712_SUBDEVICE_EWS88MT_NEW:	case ICE1712_SUBDEVICE_PHASE88:		if ((err = snd_i2c_device_create(ice->i2c, "CS8404", ICE1712_EWS88MT_CS8404_ADDR, &ice->spec.i2cdevs[EWS_I2C_CS8404])) < 0)			return err;		if ((err = snd_i2c_device_create(ice->i2c, "PCF8574 (1st)", ICE1712_EWS88MT_INPUT_ADDR, &ice->spec.i2cdevs[EWS_I2C_PCF1])) < 0)			return err;		if ((err = snd_i2c_device_create(ice->i2c, "PCF8574 (2nd)", ICE1712_EWS88MT_OUTPUT_ADDR, &ice->spec.i2cdevs[EWS_I2C_PCF2])) < 0)			return err;		/* Check if the front module is connected */		if ((err = snd_ice1712_ews88mt_chip_select(ice, 0x0f)) < 0)			return err;		break;	case ICE1712_SUBDEVICE_EWS88D:		if ((err = snd_i2c_device_create(ice->i2c, "PCF8575", ICE1712_EWS88D_PCF_ADDR, &ice->spec.i2cdevs[EWS_I2C_88D])) < 0)			return err;		break;	}	/* set up SPDIF interface */	switch (ice->eeprom.subvendor) {	case ICE1712_SUBDEVICE_EWX2496:		if ((err = snd_ice1712_init_cs8427(ice, CS8427_BASE_ADDR)) < 0)			return err;		snd_cs8427_reg_write(ice->cs8427, CS8427_REG_RECVERRMASK, CS8427_UNLOCK | CS8427_CONF | CS8427_BIP | CS8427_PAR);		break;	case ICE1712_SUBDEVICE_DMX6FIRE:		if ((err = snd_ice1712_init_cs8427(ice, ICE1712_6FIRE_CS8427_ADDR)) < 0)			return err;		snd_cs8427_reg_write(ice->cs8427, CS8427_REG_RECVERRMASK, CS8427_UNLOCK | CS8427_CONF | CS8427_BIP | CS8427_PAR);		break;	case ICE1712_SUBDEVICE_EWS88MT:	case ICE1712_SUBDEVICE_EWS88MT_NEW:	case ICE1712_SUBDEVICE_PHASE88:	case ICE1712_SUBDEVICE_EWS88D:		/* set up CS8404 */		ice->spdif.ops.open = ews88_open_spdif;		ice->spdif.ops.setup_rate = ews88_setup_spdif;		ice->spdif.ops.default_get = ews88_spdif_default_get;		ice->spdif.ops.default_put = ews88_spdif_default_put;		ice->spdif.ops.stream_get = ews88_spdif_stream_get;		ice->spdif.ops.stream_put = ews88_spdif_stream_put;		/* Set spdif defaults */		snd_ice1712_ews_cs8404_spdif_write(ice, ice->spdif.cs8403_bits);		break;	}	/* no analog? */	switch (ice->eeprom.subvendor) {	case ICE1712_SUBDEVICE_EWS88D:		return 0;	}	/* analog section */	ak = ice->akm = kmalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);	if (! ak)		return -ENOMEM;	ice->akm_codecs = 1;	switch (ice->eeprom.subvendor) {	case ICE1712_SUBDEVICE_EWS88MT:	case ICE1712_SUBDEVICE_EWS88MT_NEW:	case ICE1712_SUBDEVICE_PHASE88:		err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice);		break;	case ICE1712_SUBDEVICE_EWX2496:		err = snd_ice1712_akm4xxx_init(ak, &akm_ewx2496, &akm_ewx2496_priv, ice);		break;	case ICE1712_SUBDEVICE_DMX6FIRE:		err = snd_ice1712_akm4xxx_init(ak, &akm_6fire, &akm_6fire_priv, ice);		break;	default:		err = 0;	}	return err;}/* * EWX 24/96 specific controls *//* i/o sensitivity - this callback is shared among other devices, too */static int snd_ice1712_ewx_io_sense_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){	static char *texts[2] = {		"+4dBu", "-10dBV",	};	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;	uinfo->count = 1;	uinfo->value.enumerated.items = 2;	if (uinfo->value.enumerated.item >= 2)		uinfo->value.enumerated.item = 1;	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);	return 0;}static int snd_ice1712_ewx_io_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	unsigned char mask = kcontrol->private_value & 0xff;		snd_ice1712_save_gpio_status(ice);	ucontrol->value.enumerated.item[0] = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & mask ? 1 : 0;	snd_ice1712_restore_gpio_status(ice);	return 0;}static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	unsigned char mask = kcontrol->private_value & 0xff;	int val, nval;	if (kcontrol->private_value & (1 << 31))		return -EPERM;	nval = ucontrol->value.enumerated.item[0] ? mask : 0;	snd_ice1712_save_gpio_status(ice);	val = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);	nval |= val & ~mask;	snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, nval);	snd_ice1712_restore_gpio_status(ice);	return val != nval;}static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Input Sensitivity Switch",		.info = snd_ice1712_ewx_io_sense_info,		.get = snd_ice1712_ewx_io_sense_get,		.put = snd_ice1712_ewx_io_sense_put,		.private_value = ICE1712_EWX2496_AIN_SEL,	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Output Sensitivity Switch",		.info = snd_ice1712_ewx_io_sense_info,		.get = snd_ice1712_ewx_io_sense_get,		.put = snd_ice1712_ewx_io_sense_put,		.private_value = ICE1712_EWX2496_AOUT_SEL,	},};/* * EWS88MT specific controls *//* analog output sensitivity;; address 0x48 bit 6 */static int snd_ice1712_ews88mt_output_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	unsigned char data;	snd_i2c_lock(ice->i2c);	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {		snd_i2c_unlock(ice->i2c);		return -EIO;	}	snd_i2c_unlock(ice->i2c);	ucontrol->value.enumerated.item[0] = data & ICE1712_EWS88MT_OUTPUT_SENSE ? 1 : 0; /* high = -10dBV, low = +4dBu */	return 0;}/* analog output sensitivity;; address 0x48 bit 6 */static int snd_ice1712_ews88mt_output_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	unsigned char data, ndata;	snd_i2c_lock(ice->i2c);	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {		snd_i2c_unlock(ice->i2c);		return -EIO;	}	ndata = (data & ~ICE1712_EWS88MT_OUTPUT_SENSE) | (ucontrol->value.enumerated.item[0] ? ICE1712_EWS88MT_OUTPUT_SENSE : 0);	if (ndata != data && snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_PCF2], &ndata, 1) != 1) {		snd_i2c_unlock(ice->i2c);		return -EIO;	}	snd_i2c_unlock(ice->i2c);	return ndata != data;}/* analog input sensitivity; address 0x46 */static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);	unsigned char data;	snd_assert(channel >= 0 && channel <= 7, return 0);	snd_i2c_lock(ice->i2c);	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {		snd_i2c_unlock(ice->i2c);		return -EIO;	}	/* reversed; high = +4dBu, low = -10dBV */	ucontrol->value.enumerated.item[0] = data & (1 << channel) ? 0 : 1;	snd_i2c_unlock(ice->i2c);	return 0;}/* analog output sensitivity; address 0x46 */static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);	unsigned char data, ndata;	snd_assert(channel >= 0 && channel <= 7, return 0);	snd_i2c_lock(ice->i2c);	if (snd_i2c_readbytes(ice->spec.i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {		snd_i2c_unlock(ice->i2c);		return -EIO;	}	ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));	if (ndata != data && snd_i2c_sendbytes(ice->spec.i2cdevs[EWS_I2C_PCF1], &ndata, 1) != 1) {		snd_i2c_unlock(ice->i2c);		return -EIO;	}	snd_i2c_unlock(ice->i2c);	return ndata != data;}static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,	.name = "Input Sensitivity Switch",	.info = snd_ice1712_ewx_io_sense_info,	.get = snd_ice1712_ews88mt_input_sense_get,	.put = snd_ice1712_ews88mt_input_sense_put,	.count = 8,};static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,	.name = "Output Sensitivity Switch",

⌨️ 快捷键说明

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