aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-28 02:33:44 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:30:17 -0500
commit911b499af45e879ccf4b8db234278a7136d056c9 (patch)
tree8708445a77b89d5bd170044b7faf4c1514c8561f /sound/pci
parent236c4920ea825acbffa7bbba24c182ec6a9a8245 (diff)
[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: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/oxygen/oxygen.h2
-rw-r--r--sound/pci/oxygen/oxygen_lib.c2
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c33
-rw-r--r--sound/pci/oxygen/virtuoso.c48
4 files changed, 54 insertions, 31 deletions
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index 9ec9e6bab7d7..8fc9e7ca1182 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -84,6 +84,8 @@ struct oxygen_model {
84 struct snd_pcm_hw_params *params); 84 struct snd_pcm_hw_params *params);
85 void (*update_dac_volume)(struct oxygen *chip); 85 void (*update_dac_volume)(struct oxygen *chip);
86 void (*update_dac_mute)(struct oxygen *chip); 86 void (*update_dac_mute)(struct oxygen *chip);
87 void (*ac97_switch_hook)(struct oxygen *chip,
88 unsigned int reg, int mute);
87 size_t model_data_size; 89 size_t model_data_size;
88 u8 dac_channels; 90 u8 dac_channels;
89 u8 used_channels; 91 u8 used_channels;
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 06394e4409b3..d98867c1f2d4 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -337,8 +337,6 @@ static void __devinit oxygen_init(struct oxygen *chip)
337 oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000); 337 oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000);
338 oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080); 338 oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080);
339 oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080); 339 oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080);
340 oxygen_ac97_clear_bits(chip, 0,
341 CM9780_GPIO_STATUS, CM9780_GPO0);
342 /* power down unused ADCs and DACs */ 340 /* power down unused ADCs and DACs */
343 oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN, 341 oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN,
344 AC97_PD_PR0 | AC97_PD_PR1); 342 AC97_PD_PR0 | AC97_PD_PR1);
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index fe53318e94e0..cf34b1229b0b 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -465,19 +465,6 @@ static int ac97_switch_get(struct snd_kcontrol *ctl,
465 return 0; 465 return 0;
466} 466}
467 467
468static void ac97_mute_ctl(struct oxygen *chip, unsigned int control)
469{
470 unsigned int index = chip->controls[control]->private_value & 0xff;
471 u16 value;
472
473 value = oxygen_read_ac97(chip, 0, index);
474 if (!(value & 0x8000)) {
475 oxygen_write_ac97(chip, 0, index, value | 0x8000);
476 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
477 &chip->controls[control]->id);
478 }
479}
480
481static int ac97_switch_put(struct snd_kcontrol *ctl, 468static int ac97_switch_put(struct snd_kcontrol *ctl,
482 struct snd_ctl_elem_value *value) 469 struct snd_ctl_elem_value *value)
483{ 470{
@@ -498,22 +485,9 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
498 change = newreg != oldreg; 485 change = newreg != oldreg;
499 if (change) { 486 if (change) {
500 oxygen_write_ac97(chip, 0, index, newreg); 487 oxygen_write_ac97(chip, 0, index, newreg);
501 if (index == AC97_LINE) { 488 if (bitnr == 15 && chip->model->ac97_switch_hook)
502 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS, 489 chip->model->ac97_switch_hook(chip, index,
503 newreg & 0x8000 ? 490 newreg & 0x8000);
504 CM9780_GPO0 : 0, CM9780_GPO0);
505 if (!(newreg & 0x8000)) {
506 ac97_mute_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
507 ac97_mute_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
508 ac97_mute_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
509 }
510 } else if ((index == AC97_MIC || index == AC97_CD ||
511 index == AC97_VIDEO || index == AC97_AUX) &&
512 bitnr == 15 && !(newreg & 0x8000)) {
513 ac97_mute_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
514 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
515 CM9780_GPO0, CM9780_GPO0);
516 }
517 } 491 }
518 mutex_unlock(&chip->mutex); 492 mutex_unlock(&chip->mutex);
519 return change; 493 return change;
@@ -671,6 +645,7 @@ static const struct snd_kcontrol_new ac97_controls[] = {
671 AC97_VOLUME("Mic Capture Volume", AC97_MIC), 645 AC97_VOLUME("Mic Capture Volume", AC97_MIC),
672 AC97_SWITCH("Mic Capture Switch", AC97_MIC, 15, 1), 646 AC97_SWITCH("Mic Capture Switch", AC97_MIC, 15, 1),
673 AC97_SWITCH("Mic Boost (+20dB)", AC97_MIC, 6, 0), 647 AC97_SWITCH("Mic Boost (+20dB)", AC97_MIC, 6, 0),
648 AC97_VOLUME("Line Capture Volume", AC97_LINE),
674 AC97_SWITCH("Line Capture Switch", AC97_LINE, 15, 1), 649 AC97_SWITCH("Line Capture Switch", AC97_LINE, 15, 1),
675 AC97_VOLUME("CD Capture Volume", AC97_CD), 650 AC97_VOLUME("CD Capture Volume", AC97_CD),
676 AC97_SWITCH("CD Capture Switch", AC97_CD, 15, 1), 651 AC97_SWITCH("CD Capture Switch", AC97_CD, 15, 1),
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 665115d23627..23bfab448844 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -80,6 +80,8 @@ MODULE_DEVICE_TABLE(pci, xonar_ids);
80#define GPIO_ALT 0x0080 80#define GPIO_ALT 0x0080
81#define GPIO_OUTPUT_ENABLE 0x0100 81#define GPIO_OUTPUT_ENABLE 0x0100
82 82
83#define GPIO_LINE_MUTE CM9780_GPO0
84
83/* register 16 */ 85/* register 16 */
84#define PCM1796_ATL_MASK 0xff 86#define PCM1796_ATL_MASK 0xff
85/* register 17 */ 87/* register 17 */
@@ -168,6 +170,7 @@ static void xonar_init(struct oxygen *chip)
168 GPIO_CS5381_M_SINGLE, 170 GPIO_CS5381_M_SINGLE,
169 GPIO_CS5381_M_MASK | GPIO_ALT); 171 GPIO_CS5381_M_MASK | GPIO_ALT);
170 oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC); 172 oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC);
173 oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS, GPIO_LINE_MUTE);
171 msleep(300); 174 msleep(300);
172 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE); 175 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE);
173 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE); 176 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE);
@@ -231,6 +234,47 @@ static void set_cs5381_params(struct oxygen *chip,
231 value, GPIO_CS5381_M_MASK); 234 value, GPIO_CS5381_M_MASK);
232} 235}
233 236
237static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
238{
239 unsigned int index = chip->controls[control]->private_value & 0xff;
240 u16 value;
241
242 value = oxygen_read_ac97(chip, 0, index);
243 if (!(value & 0x8000)) {
244 oxygen_write_ac97(chip, 0, index, value | 0x8000);
245 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
246 &chip->controls[control]->id);
247 }
248}
249
250static void xonar_ac97_switch_hook(struct oxygen *chip,
251 unsigned int reg, int mute)
252{
253 /* line-in is exclusive */
254 switch (reg) {
255 case AC97_LINE:
256 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
257 mute ? GPIO_LINE_MUTE : 0,
258 GPIO_LINE_MUTE);
259 if (!mute) {
260 mute_ac97_ctl(chip, CONTROL_MIC_CAPTURE_SWITCH);
261 mute_ac97_ctl(chip, CONTROL_CD_CAPTURE_SWITCH);
262 mute_ac97_ctl(chip, CONTROL_AUX_CAPTURE_SWITCH);
263 }
264 break;
265 case AC97_MIC:
266 case AC97_CD:
267 case AC97_VIDEO:
268 case AC97_AUX:
269 if (!mute) {
270 oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_STATUS,
271 GPIO_LINE_MUTE);
272 mute_ac97_ctl(chip, CONTROL_LINE_CAPTURE_SWITCH);
273 }
274 break;
275 }
276}
277
234static int pcm1796_volume_info(struct snd_kcontrol *ctl, 278static int pcm1796_volume_info(struct snd_kcontrol *ctl,
235 struct snd_ctl_elem_info *info) 279 struct snd_ctl_elem_info *info)
236{ 280{
@@ -288,7 +332,10 @@ static int xonar_control_filter(struct snd_kcontrol_new *template)
288 template->info = pcm1796_volume_info, 332 template->info = pcm1796_volume_info,
289 template->tlv.p = pcm1796_db_scale; 333 template->tlv.p = pcm1796_db_scale;
290 } else if (!strncmp(template->name, "CD Capture ", 11)) { 334 } else if (!strncmp(template->name, "CD Capture ", 11)) {
335 /* CD in is actually connected to the video in pin */
291 template->private_value ^= AC97_CD ^ AC97_VIDEO; 336 template->private_value ^= AC97_CD ^ AC97_VIDEO;
337 } else if (!strcmp(template->name, "Line Capture Volume")) {
338 return 1; /* line-in bypasses the AC'97 mixer */
292 } 339 }
293 return 0; 340 return 0;
294} 341}
@@ -310,6 +357,7 @@ static const struct oxygen_model model_xonar = {
310 .set_adc_params = set_cs5381_params, 357 .set_adc_params = set_cs5381_params,
311 .update_dac_volume = update_pcm1796_volume, 358 .update_dac_volume = update_pcm1796_volume,
312 .update_dac_mute = update_pcm1796_mute, 359 .update_dac_mute = update_pcm1796_mute,
360 .ac97_switch_hook = xonar_ac97_switch_hook,
313 .dac_channels = 8, 361 .dac_channels = 8,
314 .used_channels = OXYGEN_CHANNEL_B | 362 .used_channels = OXYGEN_CHANNEL_B |
315 OXYGEN_CHANNEL_C | 363 OXYGEN_CHANNEL_C |