Commit 911b499a authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela

[ALSA] oxygen: make line-in exclusive only on Xonar

Move the line input switching code to the Virtuoso driver because only
the Xonar cards bypass the analog mixer for line input.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 236c4920
...@@ -84,6 +84,8 @@ struct oxygen_model { ...@@ -84,6 +84,8 @@ struct oxygen_model {
struct snd_pcm_hw_params *params); struct snd_pcm_hw_params *params);
void (*update_dac_volume)(struct oxygen *chip); void (*update_dac_volume)(struct oxygen *chip);
void (*update_dac_mute)(struct oxygen *chip); void (*update_dac_mute)(struct oxygen *chip);
void (*ac97_switch_hook)(struct oxygen *chip,
unsigned int reg, int mute);
size_t model_data_size; size_t model_data_size;
u8 dac_channels; u8 dac_channels;
u8 used_channels; u8 used_channels;
......
...@@ -337,8 +337,6 @@ static void __devinit oxygen_init(struct oxygen *chip) ...@@ -337,8 +337,6 @@ static void __devinit oxygen_init(struct oxygen *chip)
oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000); oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000);
oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080); oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080);
oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080); oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080);
oxygen_ac97_clear_bits(chip, 0,
CM9780_GPIO_STATUS, CM9780_GPO0);
/* power down unused ADCs and DACs */ /* power down unused ADCs and DACs */
oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN, oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN,
AC97_PD_PR0 | AC97_PD_PR1); AC97_PD_PR0 | AC97_PD_PR1);
......
...@@ -465,19 +465,6 @@ static int ac97_switch_get(struct snd_kcontrol *ctl, ...@@ -465,19 +465,6 @@ static int ac97_switch_get(struct snd_kcontrol *ctl,
return 0; return 0;
} }
static void ac97_mute_ctl(struct oxygen *chip, unsigned int control)
{
unsigned int index = chip->controls[control]->private_value & 0xff;
u16 value;
value = oxygen_read_ac97(chip, 0, index);
if (!(value & 0x8000)) {
oxygen_write_ac97(chip, 0, index, value | 0x8000);
snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
&chip->controls[control]->id);
}
}
static int ac97_switch_put(struct snd_kcontrol *ctl, static int ac97_switch_put(struct snd_kcontrol *ctl,
struct snd_ctl_elem_value *value) struct snd_ctl_elem_value *value)
{ {
...@@ -498,22 +485,9 @@ static int ac97_switch_put(struct snd_kcontrol *ctl, ...@@ -498,22 +485,9 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
change = newreg != oldreg; change = newreg != oldreg;
if (change) { if (change) {
oxygen_write_ac97(chip, 0, index, newreg); oxygen_write_ac97(chip, 0, index, newreg);
if (index == AC97_LINE) { if (bitnr == 15 && chip->model->ac97_switch_hook)
oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS, chip->model->ac97_switch_hook(chip, index,
newreg & 0x8000 ? newreg & 0x8000);
CM9780_GPO0 : 0, CM9780_GPO0);
if (!(newreg & 0x8000)) {
ac97_mute_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
ac97_mute_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
ac97_mute_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
}
} else if ((index == AC97_MIC || index == AC97_CD ||
index == AC97_VIDEO || index == AC97_AUX) &&
bitnr == 15 && !(newreg & 0x8000)) {
ac97_mute_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
CM9780_GPO0, CM9780_GPO0);
}
} }
mutex_unlock(&chip->mutex); mutex_unlock(&chip->mutex);
return change; return change;
...@@ -671,6 +645,7 @@ static const struct snd_kcontrol_new ac97_controls[] = { ...@@ -671,6 +645,7 @@ static const struct snd_kcontrol_new ac97_controls[] = {
AC97_VOLUME("Mic Capture Volume", AC97_MIC), AC97_VOLUME("Mic Capture Volume", AC97_MIC),
AC97_SWITCH("Mic Capture Switch", AC97_MIC, 15, 1), AC97_SWITCH("Mic Capture Switch", AC97_MIC, 15, 1),
AC97_SWITCH("Mic Boost (+20dB)", AC97_MIC, 6, 0), AC97_SWITCH("Mic Boost (+20dB)", AC97_MIC, 6, 0),
AC97_VOLUME("Line Capture Volume", AC97_LINE),
AC97_SWITCH("Line Capture Switch", AC97_LINE, 15, 1), AC97_SWITCH("Line Capture Switch", AC97_LINE, 15, 1),
AC97_VOLUME("CD Capture Volume", AC97_CD), AC97_VOLUME("CD Capture Volume", AC97_CD),
AC97_SWITCH("CD Capture Switch", AC97_CD, 15, 1), AC97_SWITCH("CD Capture Switch", AC97_CD, 15, 1),
......
...@@ -80,6 +80,8 @@ MODULE_DEVICE_TABLE(pci, xonar_ids); ...@@ -80,6 +80,8 @@ MODULE_DEVICE_TABLE(pci, xonar_ids);
#define GPIO_ALT 0x0080 #define GPIO_ALT 0x0080
#define GPIO_OUTPUT_ENABLE 0x0100 #define GPIO_OUTPUT_ENABLE 0x0100
#define GPIO_LINE_MUTE CM9780_GPO0
/* register 16 */ /* register 16 */
#define PCM1796_ATL_MASK 0xff #define PCM1796_ATL_MASK 0xff
/* register 17 */ /* register 17 */
...@@ -168,6 +170,7 @@ static void xonar_init(struct oxygen *chip) ...@@ -168,6 +170,7 @@ static void xonar_init(struct oxygen *chip)
GPIO_CS5381_M_SINGLE, GPIO_CS5381_M_SINGLE,
GPIO_CS5381_M_MASK | GPIO_ALT); GPIO_CS5381_M_MASK | GPIO_ALT);
oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC); oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC);
oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE);
msleep(300); msleep(300);
oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE); oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE);
oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE); oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE);
...@@ -231,6 +234,47 @@ static void set_cs5381_params(struct oxygen *chip, ...@@ -231,6 +234,47 @@ static void set_cs5381_params(struct oxygen *chip,
value, GPIO_CS5381_M_MASK); value, GPIO_CS5381_M_MASK);
} }
static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
{
unsigned int index = chip->controls[control]->private_value & 0xff;
u16 value;
value = oxygen_read_ac97(chip, 0, index);
if (!(value & 0x8000)) {
oxygen_write_ac97(chip, 0, index, value | 0x8000);
snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
&chip->controls[control]->id);
}
}
static void xonar_ac97_switch_hook(struct oxygen *chip,
unsigned int reg, int mute)
{
/* line-in is exclusive */
switch (reg) {
case AC97_LINE:
oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
mute ? GPIO_LINE_MUTE : 0,
GPIO_LINE_MUTE);
if (!mute) {
mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
}
break;
case AC97_MIC:
case AC97_CD:
case AC97_VIDEO:
case AC97_AUX:
if (!mute) {
oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS,
GPIO_LINE_MUTE);
mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
}
break;
}
}
static int pcm1796_volume_info(struct snd_kcontrol *ctl, static int pcm1796_volume_info(struct snd_kcontrol *ctl,
struct snd_ctl_elem_info *info) struct snd_ctl_elem_info *info)
{ {
...@@ -288,7 +332,10 @@ static int xonar_control_filter(struct snd_kcontrol_new *template) ...@@ -288,7 +332,10 @@ static int xonar_control_filter(struct snd_kcontrol_new *template)
template->info = pcm1796_volume_info, template->info = pcm1796_volume_info,
template->tlv.p = pcm1796_db_scale; template->tlv.p = pcm1796_db_scale;
} else if (!strncmp(template->name, "CD Capture ", 11)) { } else if (!strncmp(template->name, "CD Capture ", 11)) {
/* CD in is actually connected to the video in pin */
template->private_value ^= AC97_CD ^ AC97_VIDEO; template->private_value ^= AC97_CD ^ AC97_VIDEO;
} else if (!strcmp(template->name, "Line Capture Volume")) {
return 1; /* line-in bypasses the AC'97 mixer */
} }
return 0; return 0;
} }
...@@ -310,6 +357,7 @@ static const struct oxygen_model model_xonar = { ...@@ -310,6 +357,7 @@ static const struct oxygen_model model_xonar = {
.set_adc_params = set_cs5381_params, .set_adc_params = set_cs5381_params,
.update_dac_volume = update_pcm1796_volume, .update_dac_volume = update_pcm1796_volume,
.update_dac_mute = update_pcm1796_mute, .update_dac_mute = update_pcm1796_mute,
.ac97_switch_hook = xonar_ac97_switch_hook,
.dac_channels = 8, .dac_channels = 8,
.used_channels = OXYGEN_CHANNEL_B | .used_channels = OXYGEN_CHANNEL_B |
OXYGEN_CHANNEL_C | OXYGEN_CHANNEL_C |
......
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