aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-04-09 03:16:14 -0400
committerTakashi Iwai <tiwai@suse.de>2008-04-24 06:00:32 -0400
commit11864b4b84194b459fc20e0ec47906885bddb12e (patch)
treecd50f762af2aa05c25657ee7d5486a2b67d66a52 /sound/pci
parenta9d3cc485e65a56edc9ef78c034146cc8a5b3101 (diff)
[ALSA] virtuoso: correctly switch input jack on Xonar DX
When selecting the capture source on the Xonar DX, the input jack must be routed to either the line input or the microphone input by setting a GPIO pin. This requires an additional callback so that the model driver can hook into the toggling of AC97 switches. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/oxygen/oxygen.h2
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c4
-rw-r--r--sound/pci/oxygen/virtuoso.c22
3 files changed, 24 insertions, 4 deletions
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h
index d53c18c6fcd8..7efbf54bc4ec 100644
--- a/sound/pci/oxygen/oxygen.h
+++ b/sound/pci/oxygen/oxygen.h
@@ -98,6 +98,8 @@ struct oxygen_model {
98 void (*update_dac_volume)(struct oxygen *chip); 98 void (*update_dac_volume)(struct oxygen *chip);
99 void (*update_dac_mute)(struct oxygen *chip); 99 void (*update_dac_mute)(struct oxygen *chip);
100 void (*gpio_changed)(struct oxygen *chip); 100 void (*gpio_changed)(struct oxygen *chip);
101 void (*ac97_switch)(struct oxygen *chip,
102 unsigned int reg, unsigned int mute);
101 size_t model_data_size; 103 size_t model_data_size;
102 unsigned int pcm_dev_cfg; 104 unsigned int pcm_dev_cfg;
103 u8 dac_channels; 105 u8 dac_channels;
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 9a7c880eddbd..d0bef09a6999 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -518,6 +518,8 @@ static void mute_ac97_ctl(struct oxygen *chip, unsigned int control)
518 value = oxygen_read_ac97(chip, 0, priv_idx); 518 value = oxygen_read_ac97(chip, 0, priv_idx);
519 if (!(value & 0x8000)) { 519 if (!(value & 0x8000)) {
520 oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000); 520 oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000);
521 if (chip->model->ac97_switch)
522 chip->model->ac97_switch(chip, priv_idx, 0x8000);
521 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, 523 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
522 &chip->controls[control]->id); 524 &chip->controls[control]->id);
523 } 525 }
@@ -544,6 +546,8 @@ static int ac97_switch_put(struct snd_kcontrol *ctl,
544 change = newreg != oldreg; 546 change = newreg != oldreg;
545 if (change) { 547 if (change) {
546 oxygen_write_ac97(chip, codec, index, newreg); 548 oxygen_write_ac97(chip, codec, index, newreg);
549 if (codec == 0 && chip->model->ac97_switch)
550 chip->model->ac97_switch(chip, index, newreg & 0x8000);
547 if (index == AC97_LINE) { 551 if (index == AC97_LINE) {
548 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS, 552 oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS,
549 newreg & 0x8000 ? 553 newreg & 0x8000 ?
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 1db4aa5dfad4..b678e2de4adf 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -47,10 +47,10 @@
47 * GPI 0 <- external power present 47 * GPI 0 <- external power present
48 * 48 *
49 * GPIO 0 -> enable output to speakers 49 * GPIO 0 -> enable output to speakers
50 * GPIO 1 -> ALT? 50 * GPIO 1 -> ?
51 * GPIO 2 -> M0 of CS5361 51 * GPIO 2 -> M0 of CS5361
52 * GPIO 3 -> M1 of CS5361 52 * GPIO 3 -> M1 of CS5361
53 * GPIO 8 -> line-in/mic-in/digital-out switch? 53 * GPIO 8 -> route input jack to line-in (0) or mic-in (1)
54 * 54 *
55 * CS4398: 55 * CS4398:
56 * 56 *
@@ -120,7 +120,7 @@ MODULE_DEVICE_TABLE(pci, xonar_ids);
120#define GPI_DX_EXT_POWER 0x01 120#define GPI_DX_EXT_POWER 0x01
121#define GPIO_DX_OUTPUT_ENABLE 0x0001 121#define GPIO_DX_OUTPUT_ENABLE 0x0001
122#define GPIO_DX_UNKNOWN1 0x0002 122#define GPIO_DX_UNKNOWN1 0x0002
123#define GPIO_DX_UNKNOWN2 0x0100 123#define GPIO_DX_INPUT_ROUTE 0x0100
124 124
125#define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */ 125#define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */
126#define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */ 126#define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */
@@ -267,7 +267,8 @@ static void xonar_dx_init(struct oxygen *chip)
267 cs4362a_write(chip, 0x01, CS4362A_CPEN); 267 cs4362a_write(chip, 0x01, CS4362A_CPEN);
268 268
269 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 269 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL,
270 GPIO_DX_UNKNOWN1 | GPIO_DX_UNKNOWN2); 270 GPIO_DX_UNKNOWN1 | GPIO_DX_INPUT_ROUTE);
271 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_DX_INPUT_ROUTE);
271 272
272 xonar_common_init(chip); 273 xonar_common_init(chip);
273 274
@@ -469,6 +470,18 @@ static const struct snd_kcontrol_new alt_switch = {
469 .put = alt_switch_put, 470 .put = alt_switch_put,
470}; 471};
471 472
473static void xonar_dx_ac97_switch(struct oxygen *chip,
474 unsigned int reg, unsigned int mute)
475{
476 if (reg == AC97_LINE) {
477 spin_lock_irq(&chip->reg_lock);
478 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
479 mute ? GPIO_DX_INPUT_ROUTE : 0,
480 GPIO_DX_INPUT_ROUTE);
481 spin_unlock_irq(&chip->reg_lock);
482 }
483}
484
472static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -12000, 50, 0); 485static const DECLARE_TLV_DB_SCALE(pcm1796_db_scale, -12000, 50, 0);
473static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -12700, 100, 0); 486static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -12700, 100, 0);
474 487
@@ -572,6 +585,7 @@ static const struct oxygen_model xonar_models[] = {
572 .update_dac_volume = update_cs43xx_volume, 585 .update_dac_volume = update_cs43xx_volume,
573 .update_dac_mute = update_cs43xx_mute, 586 .update_dac_mute = update_cs43xx_mute,
574 .gpio_changed = xonar_gpio_changed, 587 .gpio_changed = xonar_gpio_changed,
588 .ac97_switch = xonar_dx_ac97_switch,
575 .model_data_size = sizeof(struct xonar_data), 589 .model_data_size = sizeof(struct xonar_data),
576 .pcm_dev_cfg = PLAYBACK_0_TO_I2S | 590 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
577 PLAYBACK_1_TO_SPDIF | 591 PLAYBACK_1_TO_SPDIF |