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

📄 ak4xxx-adda.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 2 页
字号:
	unsigned int mask = AK_GET_MASK(kcontrol->private_value);	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;	uinfo->count = 1;	uinfo->value.integer.min = 0;	uinfo->value.integer.max = mask;	return 0;}static int snd_akm4xxx_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);	int chip = AK_GET_CHIP(kcontrol->private_value);	int addr = AK_GET_ADDR(kcontrol->private_value);	int invert = AK_GET_INVERT(kcontrol->private_value);	unsigned int mask = AK_GET_MASK(kcontrol->private_value);	unsigned char val = snd_akm4xxx_get(ak, chip, addr);		ucontrol->value.integer.value[0] = invert ? mask - val : val;	return 0;}static int snd_akm4xxx_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);	int chip = AK_GET_CHIP(kcontrol->private_value);	int addr = AK_GET_ADDR(kcontrol->private_value);	int invert = AK_GET_INVERT(kcontrol->private_value);	unsigned int mask = AK_GET_MASK(kcontrol->private_value);	unsigned char nval = ucontrol->value.integer.value[0] % (mask+1);	int change;	if (invert)		nval = mask - nval;	change = snd_akm4xxx_get(ak, chip, addr) != nval;	if (change)		snd_akm4xxx_write(ak, chip, addr, nval);	return change;}static int snd_akm4xxx_ipga_gain_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo){	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;	uinfo->count = 1;	uinfo->value.integer.min = 0;	uinfo->value.integer.max = 36;	return 0;}static int snd_akm4xxx_ipga_gain_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);	int chip = AK_GET_CHIP(kcontrol->private_value);	int addr = AK_GET_ADDR(kcontrol->private_value);	ucontrol->value.integer.value[0] = snd_akm4xxx_get_ipga(ak, chip, addr) & 0x7f;	return 0;}static int snd_akm4xxx_ipga_gain_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);	int chip = AK_GET_CHIP(kcontrol->private_value);	int addr = AK_GET_ADDR(kcontrol->private_value);	unsigned char nval = (ucontrol->value.integer.value[0] % 37) | 0x80;	int change = snd_akm4xxx_get_ipga(ak, chip, addr) != nval;	if (change)		snd_akm4xxx_write(ak, chip, addr, nval);	return change;}static int snd_akm4xxx_deemphasis_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo){	static char *texts[4] = {		"44.1kHz", "Off", "48kHz", "32kHz",	};	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;	uinfo->count = 1;	uinfo->value.enumerated.items = 4;	if (uinfo->value.enumerated.item >= 4)		uinfo->value.enumerated.item = 3;	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);	return 0;}static int snd_akm4xxx_deemphasis_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol){	akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);	int chip = AK_GET_CHIP(kcontrol->private_value);	int addr = AK_GET_ADDR(kcontrol->private_value);	int shift = AK_GET_SHIFT(kcontrol->private_value);	ucontrol->value.enumerated.item[0] = (snd_akm4xxx_get(ak, chip, addr) >> shift) & 3;	return 0;}static int snd_akm4xxx_deemphasis_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);	int chip = AK_GET_CHIP(kcontrol->private_value);	int addr = AK_GET_ADDR(kcontrol->private_value);	int shift = AK_GET_SHIFT(kcontrol->private_value);	unsigned char nval = ucontrol->value.enumerated.item[0] & 3;	int change;		nval = (nval << shift) | (snd_akm4xxx_get(ak, chip, addr) & ~(3 << shift));	change = snd_akm4xxx_get(ak, chip, addr) != nval;	if (change)		snd_akm4xxx_write(ak, chip, addr, nval);	return change;}/* * build AK4xxx controls */int snd_akm4xxx_build_controls(akm4xxx_t *ak){	unsigned int idx, num_emphs;	snd_kcontrol_t *ctl;	int err;	ctl = kmalloc(sizeof(*ctl), GFP_KERNEL);	if (! ctl)		return -ENOMEM;	for (idx = 0; idx < ak->num_dacs; ++idx) {		memset(ctl, 0, sizeof(*ctl));		strcpy(ctl->id.name, "DAC Volume");		ctl->id.index = idx + ak->idx_offset * 2;		ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;		ctl->count = 1;		ctl->info = snd_akm4xxx_volume_info;		ctl->get = snd_akm4xxx_volume_get;		ctl->put = snd_akm4xxx_volume_put;		switch (ak->type) {		case SND_AK4524:			ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 6, 0, 127); /* register 6 & 7 */			break;		case SND_AK4528:			ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */			break;		case SND_AK4529: {			int val = idx < 6 ? idx + 2 : (idx - 6) + 0xb; /* registers 2-7 and b,c */			ctl->private_value = AK_COMPOSE(0, val, 0, 255) | AK_INVERT;			break;		}		case SND_AK4355:			ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */			break;		case SND_AK4358:			if (idx >= 6)				ctl->private_value = AK_COMPOSE(0, idx + 5, 0, 255); /* register 4-9, chip #0 only */			else				ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */			break;		case SND_AK4381:			ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255); /* register 3 & 4 */			break;		default:			err = -EINVAL;			goto __error;		}		ctl->private_data = ak;		if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)			goto __error;	}	for (idx = 0; idx < ak->num_adcs && ak->type == SND_AK4524; ++idx) {		memset(ctl, 0, sizeof(*ctl));		strcpy(ctl->id.name, "ADC Volume");		ctl->id.index = idx + ak->idx_offset * 2;		ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;		ctl->count = 1;		ctl->info = snd_akm4xxx_volume_info;		ctl->get = snd_akm4xxx_volume_get;		ctl->put = snd_akm4xxx_volume_put;		ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */		ctl->private_data = ak;		if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)			goto __error;		memset(ctl, 0, sizeof(*ctl));		strcpy(ctl->id.name, "IPGA Analog Capture Volume");		ctl->id.index = idx + ak->idx_offset * 2;		ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;		ctl->count = 1;		ctl->info = snd_akm4xxx_ipga_gain_info;		ctl->get = snd_akm4xxx_ipga_gain_get;		ctl->put = snd_akm4xxx_ipga_gain_put;		ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 0); /* register 4 & 5 */		ctl->private_data = ak;		if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)			goto __error;	}	if (ak->type == SND_AK4355 || ak->type == SND_AK4358)		num_emphs = 1;	else		num_emphs = ak->num_dacs / 2;	for (idx = 0; idx < num_emphs; idx++) {		memset(ctl, 0, sizeof(*ctl));		strcpy(ctl->id.name, "Deemphasis");		ctl->id.index = idx + ak->idx_offset;		ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;		ctl->count = 1;		ctl->info = snd_akm4xxx_deemphasis_info;		ctl->get = snd_akm4xxx_deemphasis_get;		ctl->put = snd_akm4xxx_deemphasis_put;		switch (ak->type) {		case SND_AK4524:		case SND_AK4528:			ctl->private_value = AK_COMPOSE(idx, 3, 0, 0); /* register 3 */			break;		case SND_AK4529: {			int shift = idx == 3 ? 6 : (2 - idx) * 2;			ctl->private_value = AK_COMPOSE(0, 8, shift, 0); /* register 8 with shift */			break;		}		case SND_AK4355:		case SND_AK4358:			ctl->private_value = AK_COMPOSE(idx, 3, 0, 0);			break;		case SND_AK4381:			ctl->private_value = AK_COMPOSE(idx, 1, 1, 0);			break;		}		ctl->private_data = ak;		if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)			goto __error;	}	err = 0; __error:	kfree(ctl);	return err;}static int __init alsa_akm4xxx_module_init(void){	return 0;}        static void __exit alsa_akm4xxx_module_exit(void){}        module_init(alsa_akm4xxx_module_init)module_exit(alsa_akm4xxx_module_exit)EXPORT_SYMBOL(snd_akm4xxx_write);EXPORT_SYMBOL(snd_akm4xxx_reset);EXPORT_SYMBOL(snd_akm4xxx_init);EXPORT_SYMBOL(snd_akm4xxx_build_controls);

⌨️ 快捷键说明

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