Commit 5aeb5e48 authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update - Takashi Iwai <tiwai@suse.de>

ICE1712 driver
fixes by Christoph Haderer <chris_web@gmx.at>:
- added the support of DAC/ADC mute switches
- fixed the capture route enum.
parent fc1e9e0e
......@@ -134,6 +134,47 @@ static void wm_put(ice1712_t *ice, int reg, unsigned short val)
ice->akm[0].images[reg + 1] = val;
}
/*
* DAC mute control
*/
static int wm_dac_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0;
}
static int wm_dac_mute_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, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_MUTE);
ucontrol->value.integer.value[0] = ~val>>4 & 0x1;
up(&ice->gpio_mutex);
return 0;
}
static int wm_dac_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
{
ice1712_t *ice = snd_kcontrol_chip(kcontrol);
unsigned short new, old;
int change;
snd_ice1712_save_gpio_status(ice);
old = wm_get(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_MUTE);
new = (~ucontrol->value.integer.value[0]<<4&0x10) | (old&~0x10);
change = (new != old);
if (change)
wm_put(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_MUTE, new);
snd_ice1712_restore_gpio_status(ice);
return change;
}
/*
* DAC volume attenuation mixer control
*/
......@@ -191,6 +232,47 @@ static int wm_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr
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 = 1;
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;
down(&ice->gpio_mutex);
val = wm_get(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_ADC_GAIN);
ucontrol->value.integer.value[0] = ~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 change;
snd_ice1712_save_gpio_status(ice);
old = wm_get(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_ADC_GAIN);
new = (~ucontrol->value.integer.value[0]<<5&0x20) | (old&~0x20);
change = (new != old);
if (change)
wm_put(ice, snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)+WM_ADC_GAIN, new);
snd_ice1712_restore_gpio_status(ice);
return change;
}
/*
* ADC gain mixer control
*/
......@@ -227,10 +309,10 @@ static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr
snd_ice1712_save_gpio_status(ice);
idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_ADC_GAIN;
nvol = ucontrol->value.integer.value[0];
ovol = wm_get(ice, idx) & 0x1f;
change = (ovol != nvol);
ovol = wm_get(ice, idx);
change = ((ovol & 0x1f) != nvol);
if (change)
wm_put(ice, idx, nvol);
wm_put(ice, idx, nvol | (ovol & ~0x1f));
snd_ice1712_restore_gpio_status(ice);
return change;
}
......@@ -241,18 +323,15 @@ static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr
static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
{
static char *texts[] = {
"CD Left",
"CD Right",
"Aux Left",
"Aux Right",
"Line Left",
"Line Right",
"Mic Left",
"Mic Right",
"CD", //AIN1
"Aux", //AIN2
"Line", //AIN3
"Mic", //AIN4
"AC97" //AIN5
};
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 2;
uinfo->value.enumerated.items = 8;
uinfo->count = 1;
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]);
......@@ -291,7 +370,7 @@ static int wm_adc_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucont
}
/*
* Taken from prodigy.c
* Headphone Amplifier
*/
static int aureon_set_headphone_amp(ice1712_t *ice, int enable)
{
......@@ -364,6 +443,13 @@ static snd_kcontrol_new_t aureon71_dac_control __devinitdata = {
};
static snd_kcontrol_new_t wm_controls[] __devinitdata = {
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Switch",
.info = wm_dac_mute_info,
.get = wm_dac_mute_get,
.put = wm_dac_mute_put,
},
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Master Playback Volume",
......@@ -372,6 +458,15 @@ static snd_kcontrol_new_t wm_controls[] __devinitdata = {
.put = wm_dac_vol_put,
.private_value = 1,
},
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "ADC Switch",
.count = 2,
.info = wm_adc_mute_info,
.get = wm_adc_mute_get,
.put = wm_adc_mute_put,
},
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "ADC Volume",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment