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

📄 aureon.c

📁 linux-2.6.15.6
💻 C
📖 第 1 页 / 共 4 页
字号:
		snd_ice1712_save_gpio_status(ice);		ovol = wm_get(ice, WM_OUT_MUX1);	nvol = (ovol & ~0x02) | (ucontrol->value.integer.value[0] ? 0x02 : 0x00);	if ((change = (ovol != nvol)))		wm_put(ice, WM_OUT_MUX1, nvol);			snd_ice1712_restore_gpio_status(ice);	return change;}/* * Logarithmic volume values for WM8770 * Computed as 20 * Log10(255 / x) */static unsigned char wm_vol[256] = {	127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23,	23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,	17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13,	13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,	11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8,	8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,	6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,	5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3,	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,	2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,	1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	0, 0};#define WM_VOL_MAX	(sizeof(wm_vol) - 1)#define WM_VOL_MUTE	0x8000static void wm_set_vol(ice1712_t *ice, unsigned int index, unsigned short vol, unsigned short master){	unsigned char nvol;		if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE))		nvol = 0;	else		nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX];		wm_put(ice, index, nvol);	wm_put_nocache(ice, index, 0x180 | nvol);}/* * DAC mute control */#define wm_pcm_mute_info	aureon_mono_bool_infostatic int wm_pcm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	down(&ice->gpio_mutex);	ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1;	up(&ice->gpio_mutex);	return 0;}static int wm_pcm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	unsigned short nval, oval;	int change;	snd_ice1712_save_gpio_status(ice);	oval = wm_get(ice, WM_MUTE);	nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);	if ((change = (nval != oval)))		wm_put(ice, WM_MUTE, nval);	snd_ice1712_restore_gpio_status(ice);	return change;}/* * Master volume attenuation mixer control */static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo){	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;	uinfo->count = 2;	uinfo->value.integer.min = 0;	uinfo->value.integer.max = WM_VOL_MAX;	return 0;}static int wm_master_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int i;	for (i=0; i<2; i++)		ucontrol->value.integer.value[i] = ice->spec.aureon.master[i] & ~WM_VOL_MUTE;	return 0;}static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int ch, change = 0;	snd_ice1712_save_gpio_status(ice);	for (ch = 0; ch < 2; ch++) {		if (ucontrol->value.integer.value[ch] != ice->spec.aureon.master[ch]) {			int dac;			ice->spec.aureon.master[ch] &= WM_VOL_MUTE;			ice->spec.aureon.master[ch] |= ucontrol->value.integer.value[ch];			for (dac = 0; dac < ice->num_total_dacs; dac += 2)				wm_set_vol(ice, WM_DAC_ATTEN + dac + ch,					   ice->spec.aureon.vol[dac + ch],					   ice->spec.aureon.master[ch]);			change = 1;		}	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* * DAC volume attenuation mixer control */static int wm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo){	int voices = kcontrol->private_value >> 8;	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;	uinfo->count = voices;	uinfo->value.integer.min = 0;		/* mute (-101dB) */	uinfo->value.integer.max = 0x7F;	/* 0dB */	return 0;}static int wm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int i, ofs, voices;	voices = kcontrol->private_value >> 8;	ofs = kcontrol->private_value & 0xff;	for (i = 0; i < voices; i++)		ucontrol->value.integer.value[i] = ice->spec.aureon.vol[ofs+i] & ~WM_VOL_MUTE;	return 0;}static int wm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int i, idx, ofs, voices;	int change = 0;	voices = kcontrol->private_value >> 8;	ofs = kcontrol->private_value & 0xff;	snd_ice1712_save_gpio_status(ice);	for (i = 0; i < voices; i++) {		idx  = WM_DAC_ATTEN + ofs + i;		if (ucontrol->value.integer.value[i] != ice->spec.aureon.vol[ofs+i]) {			ice->spec.aureon.vol[ofs+i] &= WM_VOL_MUTE;			ice->spec.aureon.vol[ofs+i] |= ucontrol->value.integer.value[i];			wm_set_vol(ice, idx, ice->spec.aureon.vol[ofs+i],				   ice->spec.aureon.master[i]);			change = 1;		}	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* * WM8770 mute control */static int wm_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) {	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;	uinfo->count = kcontrol->private_value >> 8;	uinfo->value.integer.min = 0;	uinfo->value.integer.max = 1;	return 0;}static int wm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int voices, ofs, i;		voices = kcontrol->private_value >> 8;	ofs = kcontrol->private_value & 0xFF;	for (i = 0; i < voices; i++)		ucontrol->value.integer.value[i] = (ice->spec.aureon.vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;	return 0;}static int wm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int change = 0, voices, ofs, i;	voices = kcontrol->private_value >> 8;	ofs = kcontrol->private_value & 0xFF;	snd_ice1712_save_gpio_status(ice);	for (i = 0; i < voices; i++) {		int val = (ice->spec.aureon.vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;		if (ucontrol->value.integer.value[i] != val) {			ice->spec.aureon.vol[ofs + i] &= ~WM_VOL_MUTE;			ice->spec.aureon.vol[ofs + i] |=				ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;			wm_set_vol(ice, ofs + i, ice->spec.aureon.vol[ofs + i],				   ice->spec.aureon.master[i]);			change = 1;		}	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* * WM8770 master mute control */static int wm_master_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) {	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;	uinfo->count = 2;	uinfo->value.integer.min = 0;	uinfo->value.integer.max = 1;	return 0;}static int wm_master_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);		ucontrol->value.integer.value[0] = (ice->spec.aureon.master[0] & WM_VOL_MUTE) ? 0 : 1;	ucontrol->value.integer.value[1] = (ice->spec.aureon.master[1] & WM_VOL_MUTE) ? 0 : 1;	return 0;}static int wm_master_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int change = 0, i;	snd_ice1712_save_gpio_status(ice);	for (i = 0; i < 2; i++) {		int val = (ice->spec.aureon.master[i] & WM_VOL_MUTE) ? 0 : 1;		if (ucontrol->value.integer.value[i] != val) {			int dac;			ice->spec.aureon.master[i] &= ~WM_VOL_MUTE;			ice->spec.aureon.master[i] |=				ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;			for (dac = 0; dac < ice->num_total_dacs; dac += 2)				wm_set_vol(ice, WM_DAC_ATTEN + dac + i,					   ice->spec.aureon.vol[dac + i],					   ice->spec.aureon.master[i]);			change = 1;		}	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* digital master volume */#define PCM_0dB 0xff#define PCM_RES 128	/* -64dB */#define PCM_MIN (PCM_0dB - PCM_RES)static int wm_pcm_vol_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;		/* mute (-64dB) */	uinfo->value.integer.max = PCM_RES;	/* 0dB */	return 0;}static int wm_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	unsigned short val;	down(&ice->gpio_mutex);	val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;	val = val > PCM_MIN ? (val - PCM_MIN) : 0;	ucontrol->value.integer.value[0] = val;	up(&ice->gpio_mutex);	return 0;}static int wm_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	unsigned short ovol, nvol;	int change = 0;	snd_ice1712_save_gpio_status(ice);	nvol = ucontrol->value.integer.value[0];	nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff;	ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;	if (ovol != nvol) {		wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */		wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100); /* update */		change = 1;	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* * ADC mute control */static int wm_adc_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo){	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;	uinfo->count = 2;	uinfo->value.integer.min = 0;	uinfo->value.integer.max = 1;	return 0;}static int wm_adc_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	unsigned short val;	int i;	down(&ice->gpio_mutex);	for (i = 0; i < 2; i++) {		val = wm_get(ice, WM_ADC_GAIN + i);		ucontrol->value.integer.value[i] = ~val>>5 & 0x1;	}	up(&ice->gpio_mutex);	return 0;}static int wm_adc_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	unsigned short new, old;	int i, change = 0;	snd_ice1712_save_gpio_status(ice);	for (i = 0; i < 2; i++) {		old = wm_get(ice, WM_ADC_GAIN + i);		new = (~ucontrol->value.integer.value[i]<<5&0x20) | (old&~0x20);		if (new != old) {			wm_put(ice, WM_ADC_GAIN + i, new);			change = 1;		}	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* * ADC gain mixer control */static int wm_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo){	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;	uinfo->count = 2;	uinfo->value.integer.min = 0;		/* -12dB */	uinfo->value.integer.max = 0x1f;	/* 19dB */	return 0;}static int wm_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int i, idx;	unsigned short vol;	down(&ice->gpio_mutex);	for (i = 0; i < 2; i++) {		idx = WM_ADC_GAIN + i;		vol = wm_get(ice, idx) & 0x1f;		ucontrol->value.integer.value[i] = vol;	}	up(&ice->gpio_mutex);	return 0;}static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	int i, idx;	unsigned short ovol, nvol;	int change = 0;	snd_ice1712_save_gpio_status(ice);	for (i = 0; i < 2; i++) {		idx  = WM_ADC_GAIN + i;		nvol = ucontrol->value.integer.value[i];		ovol = wm_get(ice, idx);		if ((ovol & 0x1f) != nvol) {			wm_put(ice, idx, nvol | (ovol & ~0x1f));			change = 1;		}	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* * ADC input mux mixer control */static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo){	static char *texts[] = {		"CD",		//AIN1		"Aux",		//AIN2		"Line",		//AIN3		"Mic",		//AIN4		"AC97"		//AIN5	};	static char *universe_texts[] = {		"Aux1",		//AIN1		"CD",		//AIN2		"Phono",	//AIN3		"Line",		//AIN4		"Aux2",		//AIN5		"Mic",		//AIN6		"Aux3",		//AIN7		"AC97"		//AIN8	};	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;	uinfo->count = 2;	if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON71_UNIVERSE) {		uinfo->value.enumerated.items = 8;		if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)			uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;		strcpy(uinfo->value.enumerated.name, universe_texts[uinfo->value.enumerated.item]);	}	else {		uinfo->value.enumerated.items = 5;		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 wm_adc_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	unsigned short val;	down(&ice->gpio_mutex);	val = wm_get(ice, WM_ADC_MUX);	ucontrol->value.integer.value[0] = val & 7;	ucontrol->value.integer.value[1] = (val >> 4) & 7;	up(&ice->gpio_mutex);	return 0;}static int wm_adc_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	unsigned short oval, nval;	int change;	snd_ice1712_save_gpio_status(ice);	oval = wm_get(ice, WM_ADC_MUX);	nval = oval & ~0x77;	nval |= ucontrol->value.integer.value[0] & 7;	nval |= (ucontrol->value.integer.value[1] & 7) << 4;	change = (oval != nval);	if (change)		wm_put(ice, WM_ADC_MUX, nval);	snd_ice1712_restore_gpio_status(ice);	return change;}/* * CS8415 Input mux */static int aureon_cs8415_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo){	ice1712_t *ice = snd_kcontrol_chip(kcontrol);	static char *aureon_texts[] = {		"CD",		//RXP0		"Optical"	//RXP1	};	static char *prodigy_texts[] = {

⌨️ 快捷键说明

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