From 387fb6a206749e13377ef8847f77d5341c281e7b Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 11 Apr 2008 10:24:48 +0200 Subject: [PATCH] [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 Signed-off-by: Takashi Iwai --- sound/pci/oxygen/virtuoso.c | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index 07d7e9b6afbb..53d7289f21c0 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, -- 2.39.5