📄 aureon.c
字号:
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(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.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(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;}/* * ADC mute control */#define wm_adc_mute_info snd_ctl_boolean_stereo_infostatic int wm_adc_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val; int i; mutex_lock(&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; } mutex_unlock(&ice->gpio_mutex); return 0;}static int wm_adc_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *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(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *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(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, idx; unsigned short vol; mutex_lock(&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; } mutex_unlock(&ice->gpio_mutex); return 0;}static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *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(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){ static const char * const texts[] = { "CD", //AIN1 "Aux", //AIN2 "Line", //AIN3 "Mic", //AIN4 "AC97" //AIN5 }; static const char * const universe_texts[] = { "Aux1", //AIN1 "CD", //AIN2 "Phono", //AIN3 "Line", //AIN4 "Aux2", //AIN5 "Mic", //AIN6 "Aux3", //AIN7 "AC97" //AIN8 }; struct snd_ice1712 *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(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_ADC_MUX); ucontrol->value.enumerated.item[0] = val & 7; ucontrol->value.enumerated.item[1] = (val >> 4) & 7; mutex_unlock(&ice->gpio_mutex); return 0;}static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *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.enumerated.item[0] & 7; nval |= (ucontrol->value.enumerated.item[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(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); static const char * const aureon_texts[] = { "CD", //RXP0 "Optical" //RXP1 }; static const char * const prodigy_texts[] = { "CD", "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; if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71) strcpy(uinfo->value.enumerated.name, prodigy_texts[uinfo->value.enumerated.item]); else strcpy(uinfo->value.enumerated.name, aureon_texts[uinfo->value.enumerated.item]); return 0;}static int aureon_cs8415_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); //snd_ice1712_save_gpio_status(ice); //val = aureon_cs8415_get(ice, CS8415_CTRL2); ucontrol->value.enumerated.item[0] = ice->spec.aureon.cs8415_mux; //snd_ice1712_restore_gpio_status(ice); return 0;}static int aureon_cs8415_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short oval, nval; int change; snd_ice1712_save_gpio_status(ice); oval = aureon_cs8415_get(ice, CS8415_CTRL2); nval = oval & ~0x07; nval |= ucontrol->value.enumerated.item[0] & 7; change = (oval != nval); if (change) aureon_cs8415_put(ice, CS8415_CTRL2, nval); snd_ice1712_restore_gpio_status(ice); ice->spec.aureon.cs8415_mux = ucontrol->value.enumerated.item[0]; return change;}static int aureon_cs8415_rate_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; uinfo->value.integer.max = 192000; return 0;}static int aureon_cs8415_rate_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char ratio; ratio = aureon_cs8415_get(ice, CS8415_RATIO); ucontrol->value.integer.value[0] = (int)((unsigned int)ratio * 750); return 0;}/* * CS8415A Mute */#define aureon_cs8415_mute_info snd_ctl_boolean_mono_infostatic int aureon_cs8415_mute_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); snd_ice1712_save_gpio_status(ice); ucontrol->value.integer.value[0] = (aureon_cs8415_get(ice, CS8415_CTRL1) & 0x20) ? 0 : 1; snd_ice1712_restore_gpio_status(ice); return 0;}static int aureon_cs8415_mute_put (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char oval, nval; int change; snd_ice1712_save_gpio_status(ice); oval = aureon_cs8415_get(ice, CS8415_CTRL1); if (ucontrol->value.integer.value[0]) nval = oval & ~0x20; else nval = oval | 0x20; if ((change = (oval != nval))) aureon_cs8415_put(ice, CS8415_CTRL1, nval); snd_ice1712_restore_gpio_status(ice); return change;}/* * CS8415A Q-Sub info */static int aureon_cs8415_qsub_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; uinfo->count = 10; return 0;}static int aureon_cs8415_qsub_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); snd_ice1712_save_gpio_status(ice); aureon_cs8415_read(ice, CS8415_QSUB, ucontrol->value.bytes.data, 10); snd_ice1712_restore_gpio_status(ice); return 0;}static int aureon_cs8415_spdif_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0;}static int aureon_cs8415_mask_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { memset(ucontrol->value.iec958.status, 0xFF, 24); return 0;}static int aureon_cs8415_spdif_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); snd_ice1712_save_gpio_status(ice); aureon_cs8415_read(ice, CS8415_C_BUFFER, ucontrol->value.iec958.status, 24); snd_ice1712_restore_gpio_status(ice); return 0;}/* * Headphone Amplifier */static int aureon_set_headphone_amp(struct snd_ice1712 *ice, int enable){ unsigned int tmp, tmp2; tmp2 = tmp = snd_ice1712_gpio_read(ice); if (enable) if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT && ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) tmp |= AUREON_HP_SEL; else tmp |= PRODIGY_HP_SEL; else if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT && ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) tmp &= ~ AUREON_HP_SEL; else tmp &= ~ PRODIGY_HP_SEL; if (tmp != tmp2) { snd_ice1712_gpio_write(ice, tmp); return 1; } return 0;}static int aureon_get_headphone_amp(struct snd_ice1712 *ice){ unsigned int tmp = snd_ice1712_gpio_read(ice); return ( tmp & AUREON_HP_SEL )!= 0;}#define aureon_hpamp_info snd_ctl_boolean_mono_infostatic int aureon_hpamp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = aureon_get_headphone_amp(ice); return 0;}static int aureon_hpamp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); return aureon_set_headphone_amp(ice,ucontrol->value.integer.value[0]);}/* * Deemphasis */#define aureon_deemp_info snd_ctl_boolean_mono_infostatic int aureon_deemp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol){ struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -