diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2009-07-13 05:39:29 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-07-15 05:55:25 -0400 |
commit | 468b8fde24d49f5b34e9152981824b9d4ecd1a2e (patch) | |
tree | fcae9bb616bed4f2a9f206543e3b7ec2e73ace0c | |
parent | 8886f33f25083a47d5fa24ad7b57bb708c5c5403 (diff) |
sound: usb-audio: Xonar U1 digital output support
Add support for the Asus Xonar U1. This device is mostly class compliant, but
the digital output requires a vendor-specific request.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/usb/usbmixer.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index 4bd3a7a0edc1..84526971e675 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c | |||
@@ -86,6 +86,7 @@ struct usb_mixer_interface { | |||
86 | u8 rc_buffer[6]; | 86 | u8 rc_buffer[6]; |
87 | 87 | ||
88 | u8 audigy2nx_leds[3]; | 88 | u8 audigy2nx_leds[3]; |
89 | u8 xonar_u1_status; | ||
89 | }; | 90 | }; |
90 | 91 | ||
91 | 92 | ||
@@ -2018,6 +2019,58 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, | |||
2018 | } | 2019 | } |
2019 | } | 2020 | } |
2020 | 2021 | ||
2022 | static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol, | ||
2023 | struct snd_ctl_elem_value *ucontrol) | ||
2024 | { | ||
2025 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); | ||
2026 | |||
2027 | ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02); | ||
2028 | return 0; | ||
2029 | } | ||
2030 | |||
2031 | static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol, | ||
2032 | struct snd_ctl_elem_value *ucontrol) | ||
2033 | { | ||
2034 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); | ||
2035 | u8 old_status, new_status; | ||
2036 | int err, changed; | ||
2037 | |||
2038 | old_status = mixer->xonar_u1_status; | ||
2039 | if (ucontrol->value.integer.value[0]) | ||
2040 | new_status = old_status | 0x02; | ||
2041 | else | ||
2042 | new_status = old_status & ~0x02; | ||
2043 | changed = new_status != old_status; | ||
2044 | err = snd_usb_ctl_msg(mixer->chip->dev, | ||
2045 | usb_sndctrlpipe(mixer->chip->dev, 0), 0x08, | ||
2046 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, | ||
2047 | 50, 0, &new_status, 1, 100); | ||
2048 | if (err < 0) | ||
2049 | return err; | ||
2050 | mixer->xonar_u1_status = new_status; | ||
2051 | return changed; | ||
2052 | } | ||
2053 | |||
2054 | static struct snd_kcontrol_new snd_xonar_u1_output_switch = { | ||
2055 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2056 | .name = "Digital Playback Switch", | ||
2057 | .info = snd_ctl_boolean_mono_info, | ||
2058 | .get = snd_xonar_u1_switch_get, | ||
2059 | .put = snd_xonar_u1_switch_put, | ||
2060 | }; | ||
2061 | |||
2062 | static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer) | ||
2063 | { | ||
2064 | int err; | ||
2065 | |||
2066 | err = snd_ctl_add(mixer->chip->card, | ||
2067 | snd_ctl_new1(&snd_xonar_u1_output_switch, mixer)); | ||
2068 | if (err < 0) | ||
2069 | return err; | ||
2070 | mixer->xonar_u1_status = 0x05; | ||
2071 | return 0; | ||
2072 | } | ||
2073 | |||
2021 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | 2074 | int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, |
2022 | int ignore_error) | 2075 | int ignore_error) |
2023 | { | 2076 | { |
@@ -2060,6 +2113,13 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, | |||
2060 | snd_audigy2nx_proc_read); | 2113 | snd_audigy2nx_proc_read); |
2061 | } | 2114 | } |
2062 | 2115 | ||
2116 | if (mixer->chip->usb_id == USB_ID(0x0b05, 0x1739) || | ||
2117 | mixer->chip->usb_id == USB_ID(0x0b05, 0x1743)) { | ||
2118 | err = snd_xonar_u1_controls_create(mixer); | ||
2119 | if (err < 0) | ||
2120 | goto _error; | ||
2121 | } | ||
2122 | |||
2063 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); | 2123 | err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops); |
2064 | if (err < 0) | 2124 | if (err < 0) |
2065 | goto _error; | 2125 | goto _error; |