diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-04-11 08:24:48 (GMT) |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-04-24 10:00:32 (GMT) |
commit | 387fb6a206749e13377ef8847f77d5341c281e7b (patch) | |
tree | e382303d237cb13051f55a9dfac5fe17ac170300 /sound/pci/oxygen/virtuoso.c | |
parent | 1d98c7d4be6ac521e3391025ddffcfe0400c798c (diff) | |
download | linux-387fb6a206749e13377ef8847f77d5341c281e7b.tar.xz |
[ALSA] virtuoso: add GPIO 1 mixer control
Add a mixer control for switching whatever it is that is connected to
GPIO pin 1 on the Xonar DX.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/oxygen/virtuoso.c')
-rw-r--r-- | sound/pci/oxygen/virtuoso.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index 07d7e9b..53d7289 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c @@ -470,6 +470,53 @@ static const struct snd_kcontrol_new alt_switch = { .put = alt_switch_put, }; +static int unknown_info(struct snd_kcontrol *ctl, + struct snd_ctl_elem_info *info) +{ + info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + info->count = 1; + info->value.enumerated.items = 2; + if (info->value.enumerated.item > 1) + info->value.enumerated.item = 1; + sprintf(info->value.enumerated.name, "%u", info->value.enumerated.item); + return 0; +} + +static int unknown_get(struct snd_kcontrol *ctl, + struct snd_ctl_elem_value *value) +{ + struct oxygen *chip = ctl->private_data; + + value->value.enumerated.item[0] = + !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DX_UNKNOWN1); + return 0; +} + +static int unknown_put(struct snd_kcontrol *ctl, + struct snd_ctl_elem_value *value) +{ + struct oxygen *chip = ctl->private_data; + u16 old_reg, new_reg; + + spin_lock_irq(&chip->reg_lock); + old_reg = oxygen_read16(chip, OXYGEN_GPIO_DATA); + if (value->value.enumerated.item[0]) + new_reg = old_reg | GPIO_DX_UNKNOWN1; + else + new_reg = old_reg & ~GPIO_DX_UNKNOWN1; + oxygen_write16(chip, OXYGEN_GPIO_DATA, new_reg); + spin_unlock_irq(&chip->reg_lock); + return old_reg != new_reg; +} + +static const struct snd_kcontrol_new unknown_switch = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "PanelConfig?", + .info = unknown_info, + .get = unknown_get, + .put = unknown_put, +}; + static void xonar_dx_ac97_switch(struct oxygen *chip, unsigned int reg, unsigned int mute) { @@ -515,6 +562,11 @@ static int xonar_mixer_init(struct oxygen *chip) return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); } +static int xonar_dx_mixer_init(struct oxygen *chip) +{ + return snd_ctl_add(chip->card, snd_ctl_new1(&unknown_switch, chip)); +} + static const struct oxygen_model xonar_models[] = { [MODEL_D2] = { .shortname = "Xonar D2", @@ -574,6 +626,7 @@ static const struct oxygen_model xonar_models[] = { .owner = THIS_MODULE, .init = xonar_dx_init, .control_filter = xonar_dx_control_filter, + .mixer_init = xonar_dx_mixer_init, .cleanup = xonar_dx_cleanup, .set_dac_params = set_cs43xx_params, .set_adc_params = set_cs53x1_params, |