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

📄 phase.c

📁 LINUX 2.6.17.4的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	uinfo->count = voices;	uinfo->value.integer.min = 0;		/* mute (-101dB) */	uinfo->value.integer.max = 0x7F;	/* 0dB */	return 0;}static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *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.phase28.vol[ofs+i] & ~WM_VOL_MUTE;	return 0;}static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *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.phase28.vol[ofs+i]) {			ice->spec.phase28.vol[ofs+i] &= WM_VOL_MUTE;			ice->spec.phase28.vol[ofs+i] |= ucontrol->value.integer.value[i];			wm_set_vol(ice, idx, ice->spec.phase28.vol[ofs+i],				   ice->spec.phase28.master[i]);			change = 1;		}	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* * WM8770 mute control */static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *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(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *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.phase28.vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;	return 0;}static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *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.phase28.vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;		if (ucontrol->value.integer.value[i] != val) {			ice->spec.phase28.vol[ofs + i] &= ~WM_VOL_MUTE;			ice->spec.phase28.vol[ofs + i] |=				ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;			wm_set_vol(ice, ofs + i, ice->spec.phase28.vol[ofs + i],				   ice->spec.phase28.master[i]);			change = 1;		}	}	snd_ice1712_restore_gpio_status(ice);	return change;}/* * WM8770 master mute control */static int wm_master_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *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(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	ucontrol->value.integer.value[0] = (ice->spec.phase28.master[0] & WM_VOL_MUTE) ? 0 : 1;	ucontrol->value.integer.value[1] = (ice->spec.phase28.master[1] & WM_VOL_MUTE) ? 0 : 1;	return 0;}static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *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.phase28.master[i] & WM_VOL_MUTE) ? 0 : 1;		if (ucontrol->value.integer.value[i] != val) {			int dac;			ice->spec.phase28.master[i] &= ~WM_VOL_MUTE;			ice->spec.phase28.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.phase28.vol[dac + i],					   ice->spec.phase28.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(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *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(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	unsigned short val;	mutex_lock(&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;	mutex_unlock(&ice->gpio_mutex);	return 0;}static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *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;}/* */static int phase28_mono_bool_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo){	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;	uinfo->count = 1;	uinfo->value.integer.min = 0;	uinfo->value.integer.max = 1;	return 0;}/* * Deemphasis */#define phase28_deemp_info	phase28_mono_bool_infostatic int phase28_deemp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf;	return 0;}static int phase28_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	int temp, temp2;	temp2 = temp = wm_get(ice, WM_DAC_CTRL2);	if (ucontrol->value.integer.value[0])		temp |= 0xf;	else		temp &= ~0xf;	if (temp != temp2) {		wm_put(ice, WM_DAC_CTRL2, temp);		return 1;	}	return 0;}/* * ADC Oversampling */static int phase28_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo){	static char *texts[2] = { "128x", "64x"	};	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 phase28_oversampling_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8;	return 0;}static int phase28_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){	int temp, temp2;	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);	temp2 = temp = wm_get(ice, WM_MASTER);	if (ucontrol->value.enumerated.item[0])		temp |= 0x8;	else		temp &= ~0x8;	if (temp != temp2) {		wm_put(ice, WM_MASTER, temp);		return 1;	}	return 0;}static struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Master Playback Switch",		.info = wm_master_mute_info,		.get = wm_master_mute_get,		.put = wm_master_mute_put	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Master Playback Volume",		.info = wm_master_vol_info,		.get = wm_master_vol_get,		.put = wm_master_vol_put	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Front Playback Switch",		.info = wm_mute_info,		.get = wm_mute_get,		.put = wm_mute_put,		.private_value = (2 << 8) | 0	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Front Playback Volume",		.info = wm_vol_info,		.get = wm_vol_get,		.put = wm_vol_put,		.private_value = (2 << 8) | 0	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Rear Playback Switch",		.info = wm_mute_info,		.get = wm_mute_get,		.put = wm_mute_put,		.private_value = (2 << 8) | 2	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Rear Playback Volume",		.info = wm_vol_info,		.get = wm_vol_get,		.put = wm_vol_put,		.private_value = (2 << 8) | 2	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Center Playback Switch",		.info = wm_mute_info,		.get = wm_mute_get,		.put = wm_mute_put,		.private_value = (1 << 8) | 4	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Center Playback Volume",		.info = wm_vol_info,		.get = wm_vol_get,		.put = wm_vol_put,		.private_value = (1 << 8) | 4	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "LFE Playback Switch",		.info = wm_mute_info,		.get = wm_mute_get,		.put = wm_mute_put,		.private_value = (1 << 8) | 5	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "LFE Playback Volume",		.info = wm_vol_info,		.get = wm_vol_get,		.put = wm_vol_put,		.private_value = (1 << 8) | 5	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Side Playback Switch",		.info = wm_mute_info,		.get = wm_mute_get,		.put = wm_mute_put,		.private_value = (2 << 8) | 6	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "Side Playback Volume",		.info = wm_vol_info,		.get = wm_vol_get,		.put = wm_vol_put,		.private_value = (2 << 8) | 6	}};static struct snd_kcontrol_new wm_controls[] __devinitdata = {	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "PCM Playback Switch",		.info = wm_pcm_mute_info,		.get = wm_pcm_mute_get,		.put = wm_pcm_mute_put	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "PCM Playback Volume",		.info = wm_pcm_vol_info,		.get = wm_pcm_vol_get,		.put = wm_pcm_vol_put	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "DAC Deemphasis Switch",		.info = phase28_deemp_info,		.get = phase28_deemp_get,		.put = phase28_deemp_put	},	{		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,		.name = "ADC Oversampling",		.info = phase28_oversampling_info,		.get = phase28_oversampling_get,		.put = phase28_oversampling_put	}};static int __devinit phase28_add_controls(struct snd_ice1712 *ice){	unsigned int i, counts;	int err;	counts = ARRAY_SIZE(phase28_dac_controls);	for (i = 0; i < counts; i++) {		err = snd_ctl_add(ice->card, snd_ctl_new1(&phase28_dac_controls[i], ice));		if (err < 0)			return err;	}	for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {		err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice));		if (err < 0)			return err;	}	return 0;}struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {	{		.subvendor = VT1724_SUBDEVICE_PHASE22,		.name = "Terratec PHASE 22",		.model = "phase22",		.chip_init = phase22_init,		.build_controls = phase22_add_controls,		.eeprom_size = sizeof(phase22_eeprom),		.eeprom_data = phase22_eeprom,	},	{		.subvendor = VT1724_SUBDEVICE_PHASE28,		.name = "Terratec PHASE 28",		.model = "phase28",		.chip_init = phase28_init,		.build_controls = phase28_add_controls,		.eeprom_size = sizeof(phase28_eeprom),		.eeprom_data = phase28_eeprom,	},	{ } /* terminator */};

⌨️ 快捷键说明

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