Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1 | /* |
| 2 | * USB Audio Driver for ALSA |
| 3 | * |
| 4 | * Quirks and vendor-specific extensions for mixer interfaces |
| 5 | * |
| 6 | * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> |
| 7 | * |
| 8 | * Many codes borrowed from audio.c by |
| 9 | * Alan Cox (alan@lxorguk.ukuu.org.uk) |
| 10 | * Thomas Sailer (sailer@ife.ee.ethz.ch) |
| 11 | * |
Przemek Rudy | 066624c | 2013-06-27 23:52:33 +0200 | [diff] [blame] | 12 | * Audio Advantage Micro II support added by: |
| 13 | * Przemek Rudy (prudy1@o2.pl) |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 14 | * |
| 15 | * This program is free software; you can redistribute it and/or modify |
| 16 | * it under the terms of the GNU General Public License as published by |
| 17 | * the Free Software Foundation; either version 2 of the License, or |
| 18 | * (at your option) any later version. |
| 19 | * |
| 20 | * This program is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * GNU General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU General Public License |
| 26 | * along with this program; if not, write to the Free Software |
| 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 28 | */ |
| 29 | |
| 30 | #include <linux/init.h> |
Stephen Rothwell | 36db045 | 2010-03-29 16:02:50 +1100 | [diff] [blame] | 31 | #include <linux/slab.h> |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 32 | #include <linux/usb.h> |
| 33 | #include <linux/usb/audio.h> |
| 34 | |
Przemek Rudy | 066624c | 2013-06-27 23:52:33 +0200 | [diff] [blame] | 35 | #include <sound/asoundef.h> |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 36 | #include <sound/core.h> |
| 37 | #include <sound/control.h> |
| 38 | #include <sound/hwdep.h> |
| 39 | #include <sound/info.h> |
| 40 | |
| 41 | #include "usbaudio.h" |
Daniel Mack | f0b5e63 | 2010-03-11 21:13:23 +0100 | [diff] [blame] | 42 | #include "mixer.h" |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 43 | #include "mixer_quirks.h" |
Chris J Arges | 76b188c | 2014-11-12 12:07:02 -0600 | [diff] [blame^] | 44 | #include "mixer_scarlett.h" |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 45 | #include "helper.h" |
| 46 | |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 47 | extern struct snd_kcontrol_new *snd_usb_feature_unit_ctl; |
| 48 | |
Mark Hills | b71dad18 | 2012-06-09 13:16:38 +0100 | [diff] [blame] | 49 | struct std_mono_table { |
| 50 | unsigned int unitid, control, cmask; |
| 51 | int val_type; |
| 52 | const char *name; |
| 53 | snd_kcontrol_tlv_rw_t *tlv_callback; |
| 54 | }; |
| 55 | |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 56 | /* This function allows for the creation of standard UAC controls. |
| 57 | * See the quirks for M-Audio FTUs or Ebox-44. |
| 58 | * If you don't want to set a TLV callback pass NULL. |
| 59 | * |
| 60 | * Since there doesn't seem to be a devices that needs a multichannel |
| 61 | * version, we keep it mono for simplicity. |
| 62 | */ |
Eldad Zack | 9f81410 | 2012-11-28 23:55:35 +0100 | [diff] [blame] | 63 | static int snd_create_std_mono_ctl_offset(struct usb_mixer_interface *mixer, |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 64 | unsigned int unitid, |
| 65 | unsigned int control, |
| 66 | unsigned int cmask, |
| 67 | int val_type, |
Eldad Zack | 9f81410 | 2012-11-28 23:55:35 +0100 | [diff] [blame] | 68 | unsigned int idx_off, |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 69 | const char *name, |
| 70 | snd_kcontrol_tlv_rw_t *tlv_callback) |
| 71 | { |
| 72 | int err; |
| 73 | struct usb_mixer_elem_info *cval; |
| 74 | struct snd_kcontrol *kctl; |
| 75 | |
| 76 | cval = kzalloc(sizeof(*cval), GFP_KERNEL); |
| 77 | if (!cval) |
| 78 | return -ENOMEM; |
| 79 | |
| 80 | cval->id = unitid; |
| 81 | cval->mixer = mixer; |
| 82 | cval->val_type = val_type; |
| 83 | cval->channels = 1; |
| 84 | cval->control = control; |
| 85 | cval->cmask = cmask; |
Eldad Zack | 9f81410 | 2012-11-28 23:55:35 +0100 | [diff] [blame] | 86 | cval->idx_off = idx_off; |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 87 | |
Mark Hills | 7df4a69 | 2012-05-11 18:31:55 +0100 | [diff] [blame] | 88 | /* get_min_max() is called only for integer volumes later, |
| 89 | * so provide a short-cut for booleans */ |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 90 | cval->min = 0; |
| 91 | cval->max = 1; |
| 92 | cval->res = 0; |
| 93 | cval->dBmin = 0; |
| 94 | cval->dBmax = 0; |
| 95 | |
| 96 | /* Create control */ |
| 97 | kctl = snd_ctl_new1(snd_usb_feature_unit_ctl, cval); |
| 98 | if (!kctl) { |
| 99 | kfree(cval); |
| 100 | return -ENOMEM; |
| 101 | } |
| 102 | |
| 103 | /* Set name */ |
| 104 | snprintf(kctl->id.name, sizeof(kctl->id.name), name); |
Chris J Arges | eef9045 | 2014-11-12 12:07:01 -0600 | [diff] [blame] | 105 | kctl->private_free = snd_usb_mixer_elem_free; |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 106 | |
| 107 | /* set TLV */ |
| 108 | if (tlv_callback) { |
| 109 | kctl->tlv.c = tlv_callback; |
| 110 | kctl->vd[0].access |= |
| 111 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 112 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; |
| 113 | } |
| 114 | /* Add control to mixer */ |
| 115 | err = snd_usb_mixer_add_control(mixer, kctl); |
| 116 | if (err < 0) |
| 117 | return err; |
| 118 | |
| 119 | return 0; |
| 120 | } |
| 121 | |
Eldad Zack | 9f81410 | 2012-11-28 23:55:35 +0100 | [diff] [blame] | 122 | static int snd_create_std_mono_ctl(struct usb_mixer_interface *mixer, |
| 123 | unsigned int unitid, |
| 124 | unsigned int control, |
| 125 | unsigned int cmask, |
| 126 | int val_type, |
| 127 | const char *name, |
| 128 | snd_kcontrol_tlv_rw_t *tlv_callback) |
| 129 | { |
| 130 | return snd_create_std_mono_ctl_offset(mixer, unitid, control, cmask, |
| 131 | val_type, 0 /* Offset */, name, tlv_callback); |
| 132 | } |
| 133 | |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 134 | /* |
Mark Hills | b71dad18 | 2012-06-09 13:16:38 +0100 | [diff] [blame] | 135 | * Create a set of standard UAC controls from a table |
| 136 | */ |
| 137 | static int snd_create_std_mono_table(struct usb_mixer_interface *mixer, |
| 138 | struct std_mono_table *t) |
| 139 | { |
| 140 | int err; |
| 141 | |
| 142 | while (t->name != NULL) { |
| 143 | err = snd_create_std_mono_ctl(mixer, t->unitid, t->control, |
| 144 | t->cmask, t->val_type, t->name, t->tlv_callback); |
| 145 | if (err < 0) |
| 146 | return err; |
| 147 | t++; |
| 148 | } |
| 149 | |
| 150 | return 0; |
| 151 | } |
| 152 | |
| 153 | /* |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 154 | * Sound Blaster remote control configuration |
| 155 | * |
| 156 | * format of remote control data: |
| 157 | * Extigy: xx 00 |
| 158 | * Audigy 2 NX: 06 80 xx 00 00 00 |
| 159 | * Live! 24-bit: 06 80 xx yy 22 83 |
| 160 | */ |
| 161 | static const struct rc_config { |
| 162 | u32 usb_id; |
| 163 | u8 offset; |
| 164 | u8 length; |
| 165 | u8 packet_length; |
| 166 | u8 min_packet_length; /* minimum accepted length of the URB result */ |
| 167 | u8 mute_mixer_id; |
| 168 | u32 mute_code; |
| 169 | } rc_configs[] = { |
| 170 | { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */ |
| 171 | { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */ |
| 172 | { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */ |
Mandar Joshi | ca8dc34 | 2010-11-02 14:43:19 +0000 | [diff] [blame] | 173 | { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */ |
Mathieu Bouffard | 7cdd8d7 | 2011-05-18 17:09:17 +0200 | [diff] [blame] | 174 | { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 175 | { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ |
| 176 | }; |
| 177 | |
| 178 | static void snd_usb_soundblaster_remote_complete(struct urb *urb) |
| 179 | { |
| 180 | struct usb_mixer_interface *mixer = urb->context; |
| 181 | const struct rc_config *rc = mixer->rc_cfg; |
| 182 | u32 code; |
| 183 | |
| 184 | if (urb->status < 0 || urb->actual_length < rc->min_packet_length) |
| 185 | return; |
| 186 | |
| 187 | code = mixer->rc_buffer[rc->offset]; |
| 188 | if (rc->length == 2) |
| 189 | code |= mixer->rc_buffer[rc->offset + 1] << 8; |
| 190 | |
| 191 | /* the Mute button actually changes the mixer control */ |
| 192 | if (code == rc->mute_code) |
| 193 | snd_usb_mixer_notify_id(mixer, rc->mute_mixer_id); |
| 194 | mixer->rc_code = code; |
| 195 | wmb(); |
| 196 | wake_up(&mixer->rc_waitq); |
| 197 | } |
| 198 | |
| 199 | static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, |
| 200 | long count, loff_t *offset) |
| 201 | { |
| 202 | struct usb_mixer_interface *mixer = hw->private_data; |
| 203 | int err; |
| 204 | u32 rc_code; |
| 205 | |
| 206 | if (count != 1 && count != 4) |
| 207 | return -EINVAL; |
| 208 | err = wait_event_interruptible(mixer->rc_waitq, |
| 209 | (rc_code = xchg(&mixer->rc_code, 0)) != 0); |
| 210 | if (err == 0) { |
| 211 | if (count == 1) |
| 212 | err = put_user(rc_code, buf); |
| 213 | else |
| 214 | err = put_user(rc_code, (u32 __user *)buf); |
| 215 | } |
| 216 | return err < 0 ? err : count; |
| 217 | } |
| 218 | |
| 219 | static unsigned int snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file, |
| 220 | poll_table *wait) |
| 221 | { |
| 222 | struct usb_mixer_interface *mixer = hw->private_data; |
| 223 | |
| 224 | poll_wait(file, &mixer->rc_waitq, wait); |
| 225 | return mixer->rc_code ? POLLIN | POLLRDNORM : 0; |
| 226 | } |
| 227 | |
| 228 | static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) |
| 229 | { |
| 230 | struct snd_hwdep *hwdep; |
| 231 | int err, len, i; |
| 232 | |
| 233 | for (i = 0; i < ARRAY_SIZE(rc_configs); ++i) |
| 234 | if (rc_configs[i].usb_id == mixer->chip->usb_id) |
| 235 | break; |
| 236 | if (i >= ARRAY_SIZE(rc_configs)) |
| 237 | return 0; |
| 238 | mixer->rc_cfg = &rc_configs[i]; |
| 239 | |
| 240 | len = mixer->rc_cfg->packet_length; |
| 241 | |
| 242 | init_waitqueue_head(&mixer->rc_waitq); |
| 243 | err = snd_hwdep_new(mixer->chip->card, "SB remote control", 0, &hwdep); |
| 244 | if (err < 0) |
| 245 | return err; |
| 246 | snprintf(hwdep->name, sizeof(hwdep->name), |
| 247 | "%s remote control", mixer->chip->card->shortname); |
| 248 | hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC; |
| 249 | hwdep->private_data = mixer; |
| 250 | hwdep->ops.read = snd_usb_sbrc_hwdep_read; |
| 251 | hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; |
| 252 | hwdep->exclusive = 1; |
| 253 | |
| 254 | mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); |
| 255 | if (!mixer->rc_urb) |
| 256 | return -ENOMEM; |
| 257 | mixer->rc_setup_packet = kmalloc(sizeof(*mixer->rc_setup_packet), GFP_KERNEL); |
| 258 | if (!mixer->rc_setup_packet) { |
| 259 | usb_free_urb(mixer->rc_urb); |
| 260 | mixer->rc_urb = NULL; |
| 261 | return -ENOMEM; |
| 262 | } |
| 263 | mixer->rc_setup_packet->bRequestType = |
| 264 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; |
| 265 | mixer->rc_setup_packet->bRequest = UAC_GET_MEM; |
| 266 | mixer->rc_setup_packet->wValue = cpu_to_le16(0); |
| 267 | mixer->rc_setup_packet->wIndex = cpu_to_le16(0); |
| 268 | mixer->rc_setup_packet->wLength = cpu_to_le16(len); |
| 269 | usb_fill_control_urb(mixer->rc_urb, mixer->chip->dev, |
| 270 | usb_rcvctrlpipe(mixer->chip->dev, 0), |
| 271 | (u8*)mixer->rc_setup_packet, mixer->rc_buffer, len, |
| 272 | snd_usb_soundblaster_remote_complete, mixer); |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | #define snd_audigy2nx_led_info snd_ctl_boolean_mono_info |
| 277 | |
| 278 | static int snd_audigy2nx_led_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 279 | { |
| 280 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 281 | int index = kcontrol->private_value; |
| 282 | |
| 283 | ucontrol->value.integer.value[0] = mixer->audigy2nx_leds[index]; |
| 284 | return 0; |
| 285 | } |
| 286 | |
| 287 | static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 288 | { |
| 289 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 290 | int index = kcontrol->private_value; |
| 291 | int value = ucontrol->value.integer.value[0]; |
| 292 | int err, changed; |
| 293 | |
| 294 | if (value > 1) |
| 295 | return -EINVAL; |
| 296 | changed = value != mixer->audigy2nx_leds[index]; |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 297 | down_read(&mixer->chip->shutdown_rwsem); |
| 298 | if (mixer->chip->shutdown) { |
| 299 | err = -ENODEV; |
| 300 | goto out; |
| 301 | } |
Mandar Joshi | ca8dc34 | 2010-11-02 14:43:19 +0000 | [diff] [blame] | 302 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) |
| 303 | err = snd_usb_ctl_msg(mixer->chip->dev, |
| 304 | usb_sndctrlpipe(mixer->chip->dev, 0), 0x24, |
| 305 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 306 | !value, 0, NULL, 0); |
Mathieu Bouffard | 7cdd8d7 | 2011-05-18 17:09:17 +0200 | [diff] [blame] | 307 | /* USB X-Fi S51 Pro */ |
| 308 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x30df)) |
| 309 | err = snd_usb_ctl_msg(mixer->chip->dev, |
| 310 | usb_sndctrlpipe(mixer->chip->dev, 0), 0x24, |
| 311 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 312 | !value, 0, NULL, 0); |
Mandar Joshi | ca8dc34 | 2010-11-02 14:43:19 +0000 | [diff] [blame] | 313 | else |
| 314 | err = snd_usb_ctl_msg(mixer->chip->dev, |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 315 | usb_sndctrlpipe(mixer->chip->dev, 0), 0x24, |
| 316 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 317 | value, index + 2, NULL, 0); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 318 | out: |
| 319 | up_read(&mixer->chip->shutdown_rwsem); |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 320 | if (err < 0) |
| 321 | return err; |
| 322 | mixer->audigy2nx_leds[index] = value; |
| 323 | return changed; |
| 324 | } |
| 325 | |
| 326 | static struct snd_kcontrol_new snd_audigy2nx_controls[] = { |
| 327 | { |
| 328 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 329 | .name = "CMSS LED Switch", |
| 330 | .info = snd_audigy2nx_led_info, |
| 331 | .get = snd_audigy2nx_led_get, |
| 332 | .put = snd_audigy2nx_led_put, |
| 333 | .private_value = 0, |
| 334 | }, |
| 335 | { |
| 336 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 337 | .name = "Power LED Switch", |
| 338 | .info = snd_audigy2nx_led_info, |
| 339 | .get = snd_audigy2nx_led_get, |
| 340 | .put = snd_audigy2nx_led_put, |
| 341 | .private_value = 1, |
| 342 | }, |
| 343 | { |
| 344 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 345 | .name = "Dolby Digital LED Switch", |
| 346 | .info = snd_audigy2nx_led_info, |
| 347 | .get = snd_audigy2nx_led_get, |
| 348 | .put = snd_audigy2nx_led_put, |
| 349 | .private_value = 2, |
| 350 | }, |
| 351 | }; |
| 352 | |
| 353 | static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer) |
| 354 | { |
| 355 | int i, err; |
| 356 | |
| 357 | for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) { |
Mandar Joshi | ca8dc34 | 2010-11-02 14:43:19 +0000 | [diff] [blame] | 358 | /* USB X-Fi S51 doesn't have a CMSS LED */ |
| 359 | if ((mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) && i == 0) |
| 360 | continue; |
Mathieu Bouffard | 7cdd8d7 | 2011-05-18 17:09:17 +0200 | [diff] [blame] | 361 | /* USB X-Fi S51 Pro doesn't have one either */ |
| 362 | if ((mixer->chip->usb_id == USB_ID(0x041e, 0x30df)) && i == 0) |
| 363 | continue; |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 364 | if (i > 1 && /* Live24ext has 2 LEDs only */ |
| 365 | (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || |
Mandar Joshi | ca8dc34 | 2010-11-02 14:43:19 +0000 | [diff] [blame] | 366 | mixer->chip->usb_id == USB_ID(0x041e, 0x3042) || |
Mathieu Bouffard | 7cdd8d7 | 2011-05-18 17:09:17 +0200 | [diff] [blame] | 367 | mixer->chip->usb_id == USB_ID(0x041e, 0x30df) || |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 368 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048))) |
| 369 | break; |
| 370 | err = snd_ctl_add(mixer->chip->card, |
| 371 | snd_ctl_new1(&snd_audigy2nx_controls[i], mixer)); |
| 372 | if (err < 0) |
| 373 | return err; |
| 374 | } |
| 375 | mixer->audigy2nx_leds[1] = 1; /* Power LED is on by default */ |
| 376 | return 0; |
| 377 | } |
| 378 | |
| 379 | static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, |
| 380 | struct snd_info_buffer *buffer) |
| 381 | { |
| 382 | static const struct sb_jack { |
| 383 | int unitid; |
| 384 | const char *name; |
| 385 | } jacks_audigy2nx[] = { |
| 386 | {4, "dig in "}, |
| 387 | {7, "line in"}, |
| 388 | {19, "spk out"}, |
| 389 | {20, "hph out"}, |
| 390 | {-1, NULL} |
| 391 | }, jacks_live24ext[] = { |
| 392 | {4, "line in"}, /* &1=Line, &2=Mic*/ |
| 393 | {3, "hph out"}, /* headphones */ |
| 394 | {0, "RC "}, /* last command, 6 bytes see rc_config above */ |
| 395 | {-1, NULL} |
| 396 | }; |
| 397 | const struct sb_jack *jacks; |
| 398 | struct usb_mixer_interface *mixer = entry->private_data; |
| 399 | int i, err; |
| 400 | u8 buf[3]; |
| 401 | |
| 402 | snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname); |
| 403 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) |
| 404 | jacks = jacks_audigy2nx; |
| 405 | else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || |
| 406 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) |
| 407 | jacks = jacks_live24ext; |
| 408 | else |
| 409 | return; |
| 410 | |
| 411 | for (i = 0; jacks[i].name; ++i) { |
| 412 | snd_iprintf(buffer, "%s: ", jacks[i].name); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 413 | down_read(&mixer->chip->shutdown_rwsem); |
| 414 | if (mixer->chip->shutdown) |
| 415 | err = 0; |
| 416 | else |
| 417 | err = snd_usb_ctl_msg(mixer->chip->dev, |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 418 | usb_rcvctrlpipe(mixer->chip->dev, 0), |
| 419 | UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | |
| 420 | USB_RECIP_INTERFACE, 0, |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 421 | jacks[i].unitid << 8, buf, 3); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 422 | up_read(&mixer->chip->shutdown_rwsem); |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 423 | if (err == 3 && (buf[0] == 3 || buf[0] == 6)) |
| 424 | snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]); |
| 425 | else |
| 426 | snd_iprintf(buffer, "?\n"); |
| 427 | } |
| 428 | } |
| 429 | |
Vasily Khoruzhick | 44832a7 | 2013-11-13 13:13:35 +0300 | [diff] [blame] | 430 | /* EMU0204 */ |
| 431 | static int snd_emu0204_ch_switch_info(struct snd_kcontrol *kcontrol, |
| 432 | struct snd_ctl_elem_info *uinfo) |
| 433 | { |
Takashi Iwai | 7bbd03e | 2014-10-20 18:21:42 +0200 | [diff] [blame] | 434 | static const char * const texts[2] = {"1/2", "3/4"}; |
Vasily Khoruzhick | 44832a7 | 2013-11-13 13:13:35 +0300 | [diff] [blame] | 435 | |
Takashi Iwai | 7bbd03e | 2014-10-20 18:21:42 +0200 | [diff] [blame] | 436 | return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts); |
Vasily Khoruzhick | 44832a7 | 2013-11-13 13:13:35 +0300 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | static int snd_emu0204_ch_switch_get(struct snd_kcontrol *kcontrol, |
| 440 | struct snd_ctl_elem_value *ucontrol) |
| 441 | { |
| 442 | ucontrol->value.enumerated.item[0] = kcontrol->private_value; |
| 443 | return 0; |
| 444 | } |
| 445 | |
| 446 | static int snd_emu0204_ch_switch_put(struct snd_kcontrol *kcontrol, |
| 447 | struct snd_ctl_elem_value *ucontrol) |
| 448 | { |
| 449 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 450 | unsigned int value = ucontrol->value.enumerated.item[0]; |
| 451 | int err, changed; |
| 452 | unsigned char buf[2]; |
| 453 | |
| 454 | if (value > 1) |
| 455 | return -EINVAL; |
| 456 | |
| 457 | buf[0] = 0x01; |
| 458 | buf[1] = value ? 0x02 : 0x01; |
| 459 | |
| 460 | changed = value != kcontrol->private_value; |
| 461 | down_read(&mixer->chip->shutdown_rwsem); |
| 462 | if (mixer->chip->shutdown) { |
| 463 | err = -ENODEV; |
| 464 | goto out; |
| 465 | } |
| 466 | err = snd_usb_ctl_msg(mixer->chip->dev, |
| 467 | usb_sndctrlpipe(mixer->chip->dev, 0), UAC_SET_CUR, |
| 468 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, |
| 469 | 0x0400, 0x0e00, buf, 2); |
| 470 | out: |
| 471 | up_read(&mixer->chip->shutdown_rwsem); |
| 472 | if (err < 0) |
| 473 | return err; |
| 474 | kcontrol->private_value = value; |
| 475 | return changed; |
| 476 | } |
| 477 | |
| 478 | |
| 479 | static struct snd_kcontrol_new snd_emu0204_controls[] = { |
| 480 | { |
| 481 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 482 | .name = "Front Jack Channels", |
| 483 | .info = snd_emu0204_ch_switch_info, |
| 484 | .get = snd_emu0204_ch_switch_get, |
| 485 | .put = snd_emu0204_ch_switch_put, |
| 486 | .private_value = 0, |
| 487 | }, |
| 488 | }; |
| 489 | |
| 490 | static int snd_emu0204_controls_create(struct usb_mixer_interface *mixer) |
| 491 | { |
| 492 | int i, err; |
| 493 | |
| 494 | for (i = 0; i < ARRAY_SIZE(snd_emu0204_controls); ++i) { |
| 495 | err = snd_ctl_add(mixer->chip->card, |
| 496 | snd_ctl_new1(&snd_emu0204_controls[i], mixer)); |
| 497 | if (err < 0) |
| 498 | return err; |
| 499 | } |
| 500 | |
| 501 | return 0; |
| 502 | } |
Denis Washington | 1d31aff | 2012-12-11 11:38:32 +0100 | [diff] [blame] | 503 | /* ASUS Xonar U1 / U3 controls */ |
| 504 | |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 505 | static int snd_xonar_u1_switch_get(struct snd_kcontrol *kcontrol, |
| 506 | struct snd_ctl_elem_value *ucontrol) |
| 507 | { |
| 508 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 509 | |
| 510 | ucontrol->value.integer.value[0] = !!(mixer->xonar_u1_status & 0x02); |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol, |
| 515 | struct snd_ctl_elem_value *ucontrol) |
| 516 | { |
| 517 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 518 | u8 old_status, new_status; |
| 519 | int err, changed; |
| 520 | |
| 521 | old_status = mixer->xonar_u1_status; |
| 522 | if (ucontrol->value.integer.value[0]) |
| 523 | new_status = old_status | 0x02; |
| 524 | else |
| 525 | new_status = old_status & ~0x02; |
| 526 | changed = new_status != old_status; |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 527 | down_read(&mixer->chip->shutdown_rwsem); |
| 528 | if (mixer->chip->shutdown) |
| 529 | err = -ENODEV; |
| 530 | else |
| 531 | err = snd_usb_ctl_msg(mixer->chip->dev, |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 532 | usb_sndctrlpipe(mixer->chip->dev, 0), 0x08, |
| 533 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
Clemens Ladisch | 17d900c | 2011-09-26 21:15:27 +0200 | [diff] [blame] | 534 | 50, 0, &new_status, 1); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 535 | up_read(&mixer->chip->shutdown_rwsem); |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 536 | if (err < 0) |
| 537 | return err; |
| 538 | mixer->xonar_u1_status = new_status; |
| 539 | return changed; |
| 540 | } |
| 541 | |
| 542 | static struct snd_kcontrol_new snd_xonar_u1_output_switch = { |
| 543 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 544 | .name = "Digital Playback Switch", |
| 545 | .info = snd_ctl_boolean_mono_info, |
| 546 | .get = snd_xonar_u1_switch_get, |
| 547 | .put = snd_xonar_u1_switch_put, |
| 548 | }; |
| 549 | |
| 550 | static int snd_xonar_u1_controls_create(struct usb_mixer_interface *mixer) |
| 551 | { |
| 552 | int err; |
| 553 | |
| 554 | err = snd_ctl_add(mixer->chip->card, |
| 555 | snd_ctl_new1(&snd_xonar_u1_output_switch, mixer)); |
| 556 | if (err < 0) |
| 557 | return err; |
| 558 | mixer->xonar_u1_status = 0x05; |
| 559 | return 0; |
| 560 | } |
| 561 | |
Damien Zammit | d497a82 | 2014-11-12 01:09:54 +1100 | [diff] [blame] | 562 | /* Digidesign Mbox 1 clock source switch (internal/spdif) */ |
| 563 | |
| 564 | static int snd_mbox1_switch_get(struct snd_kcontrol *kctl, |
| 565 | struct snd_ctl_elem_value *ucontrol) |
| 566 | { |
| 567 | ucontrol->value.enumerated.item[0] = kctl->private_value; |
| 568 | return 0; |
| 569 | } |
| 570 | |
| 571 | static int snd_mbox1_switch_put(struct snd_kcontrol *kctl, |
| 572 | struct snd_ctl_elem_value *ucontrol) |
| 573 | { |
| 574 | struct snd_usb_audio *chip; |
| 575 | struct usb_mixer_interface *mixer; |
| 576 | int err; |
| 577 | bool cur_val, new_val; |
| 578 | unsigned char buff[3]; |
| 579 | |
| 580 | cur_val = kctl->private_value; |
| 581 | new_val = ucontrol->value.enumerated.item[0]; |
| 582 | |
| 583 | mixer = snd_kcontrol_chip(kctl); |
| 584 | if (snd_BUG_ON(!mixer)) |
| 585 | return -EINVAL; |
| 586 | |
| 587 | chip = mixer->chip; |
| 588 | if (snd_BUG_ON(!chip)) |
| 589 | return -EINVAL; |
| 590 | |
| 591 | if (cur_val == new_val) |
| 592 | return 0; |
| 593 | |
| 594 | down_read(&chip->shutdown_rwsem); |
| 595 | if (chip->shutdown) { |
| 596 | err = -ENODEV; |
| 597 | goto err; |
| 598 | } |
| 599 | |
| 600 | /* Prepare for magic command to toggle clock source */ |
| 601 | err = snd_usb_ctl_msg(chip->dev, |
| 602 | usb_rcvctrlpipe(chip->dev, 0), 0x81, |
| 603 | USB_DIR_IN | |
| 604 | USB_TYPE_CLASS | |
| 605 | USB_RECIP_INTERFACE, 0x00, 0x500, buff, 1); |
| 606 | if (err < 0) |
| 607 | goto err; |
| 608 | err = snd_usb_ctl_msg(chip->dev, |
| 609 | usb_rcvctrlpipe(chip->dev, 0), 0x81, |
| 610 | USB_DIR_IN | |
| 611 | USB_TYPE_CLASS | |
| 612 | USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3); |
| 613 | if (err < 0) |
| 614 | goto err; |
| 615 | |
| 616 | /* 2 possibilities: Internal -> send sample rate |
| 617 | * S/PDIF sync -> send zeroes |
| 618 | * NB: Sample rate locked to 48kHz on purpose to |
| 619 | * prevent user from resetting the sample rate |
| 620 | * while S/PDIF sync is enabled and confusing |
| 621 | * this configuration. |
| 622 | */ |
| 623 | if (new_val == 0) { |
| 624 | buff[0] = 0x80; |
| 625 | buff[1] = 0xbb; |
| 626 | buff[2] = 0x00; |
| 627 | } else { |
| 628 | buff[0] = buff[1] = buff[2] = 0x00; |
| 629 | } |
| 630 | |
| 631 | /* Send the magic command to toggle the clock source */ |
| 632 | err = snd_usb_ctl_msg(chip->dev, |
| 633 | usb_sndctrlpipe(chip->dev, 0), 0x1, |
| 634 | USB_TYPE_CLASS | |
| 635 | USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3); |
| 636 | if (err < 0) |
| 637 | goto err; |
| 638 | err = snd_usb_ctl_msg(chip->dev, |
| 639 | usb_rcvctrlpipe(chip->dev, 0), 0x81, |
| 640 | USB_DIR_IN | |
| 641 | USB_TYPE_CLASS | |
| 642 | USB_RECIP_ENDPOINT, 0x100, 0x81, buff, 3); |
| 643 | if (err < 0) |
| 644 | goto err; |
| 645 | err = snd_usb_ctl_msg(chip->dev, |
| 646 | usb_rcvctrlpipe(chip->dev, 0), 0x81, |
| 647 | USB_DIR_IN | |
| 648 | USB_TYPE_CLASS | |
| 649 | USB_RECIP_ENDPOINT, 0x100, 0x2, buff, 3); |
| 650 | if (err < 0) |
| 651 | goto err; |
| 652 | kctl->private_value = new_val; |
| 653 | |
| 654 | err: |
| 655 | up_read(&chip->shutdown_rwsem); |
| 656 | return err < 0 ? err : 1; |
| 657 | } |
| 658 | |
| 659 | static int snd_mbox1_switch_info(struct snd_kcontrol *kcontrol, |
| 660 | struct snd_ctl_elem_info *uinfo) |
| 661 | { |
| 662 | static const char *const texts[2] = { |
| 663 | "Internal", |
| 664 | "S/PDIF" |
| 665 | }; |
| 666 | |
| 667 | return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts); |
| 668 | } |
| 669 | |
| 670 | static struct snd_kcontrol_new snd_mbox1_switch = { |
| 671 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 672 | .name = "Clock Source", |
| 673 | .index = 0, |
| 674 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, |
| 675 | .info = snd_mbox1_switch_info, |
| 676 | .get = snd_mbox1_switch_get, |
| 677 | .put = snd_mbox1_switch_put, |
| 678 | .private_value = 0 |
| 679 | }; |
| 680 | |
| 681 | static int snd_mbox1_create_sync_switch(struct usb_mixer_interface *mixer) |
| 682 | { |
| 683 | return snd_ctl_add(mixer->chip->card, |
| 684 | snd_ctl_new1(&snd_mbox1_switch, mixer)); |
| 685 | } |
| 686 | |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 687 | /* Native Instruments device quirks */ |
| 688 | |
| 689 | #define _MAKE_NI_CONTROL(bRequest,wIndex) ((bRequest) << 16 | (wIndex)) |
| 690 | |
| 691 | static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol, |
| 692 | struct snd_ctl_elem_value *ucontrol) |
| 693 | { |
| 694 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 695 | struct usb_device *dev = mixer->chip->dev; |
| 696 | u8 bRequest = (kcontrol->private_value >> 16) & 0xff; |
| 697 | u16 wIndex = kcontrol->private_value & 0xffff; |
| 698 | u8 tmp; |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 699 | int ret; |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 700 | |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 701 | down_read(&mixer->chip->shutdown_rwsem); |
| 702 | if (mixer->chip->shutdown) |
| 703 | ret = -ENODEV; |
| 704 | else |
| 705 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest, |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 706 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, |
Eldad Zack | 889d668 | 2013-04-05 20:49:46 +0200 | [diff] [blame] | 707 | 0, wIndex, |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 708 | &tmp, sizeof(tmp), 1000); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 709 | up_read(&mixer->chip->shutdown_rwsem); |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 710 | |
| 711 | if (ret < 0) { |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 712 | dev_err(&dev->dev, |
| 713 | "unable to issue vendor read request (ret = %d)", ret); |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 714 | return ret; |
| 715 | } |
| 716 | |
| 717 | ucontrol->value.integer.value[0] = tmp; |
| 718 | |
| 719 | return 0; |
| 720 | } |
| 721 | |
| 722 | static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol, |
| 723 | struct snd_ctl_elem_value *ucontrol) |
| 724 | { |
| 725 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 726 | struct usb_device *dev = mixer->chip->dev; |
| 727 | u8 bRequest = (kcontrol->private_value >> 16) & 0xff; |
| 728 | u16 wIndex = kcontrol->private_value & 0xffff; |
| 729 | u16 wValue = ucontrol->value.integer.value[0]; |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 730 | int ret; |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 731 | |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 732 | down_read(&mixer->chip->shutdown_rwsem); |
| 733 | if (mixer->chip->shutdown) |
| 734 | ret = -ENODEV; |
| 735 | else |
| 736 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest, |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 737 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, |
Eldad Zack | 889d668 | 2013-04-05 20:49:46 +0200 | [diff] [blame] | 738 | wValue, wIndex, |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 739 | NULL, 0, 1000); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 740 | up_read(&mixer->chip->shutdown_rwsem); |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 741 | |
| 742 | if (ret < 0) { |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 743 | dev_err(&dev->dev, |
| 744 | "unable to issue vendor write request (ret = %d)", ret); |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 745 | return ret; |
| 746 | } |
| 747 | |
| 748 | return 0; |
| 749 | } |
| 750 | |
| 751 | static struct snd_kcontrol_new snd_nativeinstruments_ta6_mixers[] = { |
| 752 | { |
| 753 | .name = "Direct Thru Channel A", |
| 754 | .private_value = _MAKE_NI_CONTROL(0x01, 0x03), |
| 755 | }, |
| 756 | { |
| 757 | .name = "Direct Thru Channel B", |
| 758 | .private_value = _MAKE_NI_CONTROL(0x01, 0x05), |
| 759 | }, |
| 760 | { |
| 761 | .name = "Phono Input Channel A", |
| 762 | .private_value = _MAKE_NI_CONTROL(0x02, 0x03), |
| 763 | }, |
| 764 | { |
| 765 | .name = "Phono Input Channel B", |
| 766 | .private_value = _MAKE_NI_CONTROL(0x02, 0x05), |
| 767 | }, |
| 768 | }; |
| 769 | |
| 770 | static struct snd_kcontrol_new snd_nativeinstruments_ta10_mixers[] = { |
| 771 | { |
| 772 | .name = "Direct Thru Channel A", |
| 773 | .private_value = _MAKE_NI_CONTROL(0x01, 0x03), |
| 774 | }, |
| 775 | { |
| 776 | .name = "Direct Thru Channel B", |
| 777 | .private_value = _MAKE_NI_CONTROL(0x01, 0x05), |
| 778 | }, |
| 779 | { |
| 780 | .name = "Direct Thru Channel C", |
| 781 | .private_value = _MAKE_NI_CONTROL(0x01, 0x07), |
| 782 | }, |
| 783 | { |
| 784 | .name = "Direct Thru Channel D", |
| 785 | .private_value = _MAKE_NI_CONTROL(0x01, 0x09), |
| 786 | }, |
| 787 | { |
| 788 | .name = "Phono Input Channel A", |
| 789 | .private_value = _MAKE_NI_CONTROL(0x02, 0x03), |
| 790 | }, |
| 791 | { |
| 792 | .name = "Phono Input Channel B", |
| 793 | .private_value = _MAKE_NI_CONTROL(0x02, 0x05), |
| 794 | }, |
| 795 | { |
| 796 | .name = "Phono Input Channel C", |
| 797 | .private_value = _MAKE_NI_CONTROL(0x02, 0x07), |
| 798 | }, |
| 799 | { |
| 800 | .name = "Phono Input Channel D", |
| 801 | .private_value = _MAKE_NI_CONTROL(0x02, 0x09), |
| 802 | }, |
| 803 | }; |
| 804 | |
| 805 | static int snd_nativeinstruments_create_mixer(struct usb_mixer_interface *mixer, |
| 806 | const struct snd_kcontrol_new *kc, |
| 807 | unsigned int count) |
| 808 | { |
| 809 | int i, err = 0; |
| 810 | struct snd_kcontrol_new template = { |
| 811 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 812 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, |
| 813 | .get = snd_nativeinstruments_control_get, |
| 814 | .put = snd_nativeinstruments_control_put, |
| 815 | .info = snd_ctl_boolean_mono_info, |
| 816 | }; |
| 817 | |
| 818 | for (i = 0; i < count; i++) { |
| 819 | struct snd_kcontrol *c; |
| 820 | |
| 821 | template.name = kc[i].name; |
| 822 | template.private_value = kc[i].private_value; |
| 823 | |
| 824 | c = snd_ctl_new1(&template, mixer); |
| 825 | err = snd_ctl_add(mixer->chip->card, c); |
| 826 | |
| 827 | if (err < 0) |
| 828 | break; |
| 829 | } |
| 830 | |
| 831 | return err; |
| 832 | } |
| 833 | |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 834 | /* M-Audio FastTrack Ultra quirks */ |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 835 | /* FTU Effect switch (also used by C400/C600) */ |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 836 | struct snd_ftu_eff_switch_priv_val { |
| 837 | struct usb_mixer_interface *mixer; |
| 838 | int cached_value; |
| 839 | int is_cached; |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 840 | int bUnitID; |
| 841 | int validx; |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 842 | }; |
| 843 | |
| 844 | static int snd_ftu_eff_switch_info(struct snd_kcontrol *kcontrol, |
| 845 | struct snd_ctl_elem_info *uinfo) |
| 846 | { |
Takashi Iwai | 7bbd03e | 2014-10-20 18:21:42 +0200 | [diff] [blame] | 847 | static const char *const texts[8] = { |
| 848 | "Room 1", "Room 2", "Room 3", "Hall 1", |
| 849 | "Hall 2", "Plate", "Delay", "Echo" |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 850 | }; |
| 851 | |
Takashi Iwai | 7bbd03e | 2014-10-20 18:21:42 +0200 | [diff] [blame] | 852 | return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts); |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl, |
| 856 | struct snd_ctl_elem_value *ucontrol) |
| 857 | { |
| 858 | struct snd_usb_audio *chip; |
| 859 | struct usb_mixer_interface *mixer; |
| 860 | struct snd_ftu_eff_switch_priv_val *pval; |
| 861 | int err; |
| 862 | unsigned char value[2]; |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 863 | int id, validx; |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 864 | |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 865 | const int val_len = 2; |
| 866 | |
| 867 | value[0] = 0x00; |
| 868 | value[1] = 0x00; |
| 869 | |
| 870 | pval = (struct snd_ftu_eff_switch_priv_val *) |
| 871 | kctl->private_value; |
| 872 | |
| 873 | if (pval->is_cached) { |
| 874 | ucontrol->value.enumerated.item[0] = pval->cached_value; |
| 875 | return 0; |
| 876 | } |
| 877 | |
| 878 | mixer = (struct usb_mixer_interface *) pval->mixer; |
| 879 | if (snd_BUG_ON(!mixer)) |
| 880 | return -EINVAL; |
| 881 | |
| 882 | chip = (struct snd_usb_audio *) mixer->chip; |
| 883 | if (snd_BUG_ON(!chip)) |
| 884 | return -EINVAL; |
| 885 | |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 886 | id = pval->bUnitID; |
| 887 | validx = pval->validx; |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 888 | |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 889 | down_read(&mixer->chip->shutdown_rwsem); |
| 890 | if (mixer->chip->shutdown) |
| 891 | err = -ENODEV; |
| 892 | else |
| 893 | err = snd_usb_ctl_msg(chip->dev, |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 894 | usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR, |
| 895 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, |
| 896 | validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), |
| 897 | value, val_len); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 898 | up_read(&mixer->chip->shutdown_rwsem); |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 899 | if (err < 0) |
| 900 | return err; |
| 901 | |
| 902 | ucontrol->value.enumerated.item[0] = value[0]; |
| 903 | pval->cached_value = value[0]; |
| 904 | pval->is_cached = 1; |
| 905 | |
| 906 | return 0; |
| 907 | } |
| 908 | |
| 909 | static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl, |
| 910 | struct snd_ctl_elem_value *ucontrol) |
| 911 | { |
| 912 | struct snd_usb_audio *chip; |
| 913 | struct snd_ftu_eff_switch_priv_val *pval; |
| 914 | |
| 915 | struct usb_mixer_interface *mixer; |
| 916 | int changed, cur_val, err, new_val; |
| 917 | unsigned char value[2]; |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 918 | int id, validx; |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 919 | |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 920 | const int val_len = 2; |
| 921 | |
| 922 | changed = 0; |
| 923 | |
| 924 | pval = (struct snd_ftu_eff_switch_priv_val *) |
| 925 | kctl->private_value; |
| 926 | cur_val = pval->cached_value; |
| 927 | new_val = ucontrol->value.enumerated.item[0]; |
| 928 | |
| 929 | mixer = (struct usb_mixer_interface *) pval->mixer; |
| 930 | if (snd_BUG_ON(!mixer)) |
| 931 | return -EINVAL; |
| 932 | |
| 933 | chip = (struct snd_usb_audio *) mixer->chip; |
| 934 | if (snd_BUG_ON(!chip)) |
| 935 | return -EINVAL; |
| 936 | |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 937 | id = pval->bUnitID; |
| 938 | validx = pval->validx; |
| 939 | |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 940 | if (!pval->is_cached) { |
| 941 | /* Read current value */ |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 942 | down_read(&mixer->chip->shutdown_rwsem); |
| 943 | if (mixer->chip->shutdown) |
| 944 | err = -ENODEV; |
| 945 | else |
| 946 | err = snd_usb_ctl_msg(chip->dev, |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 947 | usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR, |
| 948 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, |
| 949 | validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), |
| 950 | value, val_len); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 951 | up_read(&mixer->chip->shutdown_rwsem); |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 952 | if (err < 0) |
| 953 | return err; |
| 954 | |
| 955 | cur_val = value[0]; |
| 956 | pval->cached_value = cur_val; |
| 957 | pval->is_cached = 1; |
| 958 | } |
| 959 | /* update value if needed */ |
| 960 | if (cur_val != new_val) { |
| 961 | value[0] = new_val; |
| 962 | value[1] = 0; |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 963 | down_read(&mixer->chip->shutdown_rwsem); |
| 964 | if (mixer->chip->shutdown) |
| 965 | err = -ENODEV; |
| 966 | else |
| 967 | err = snd_usb_ctl_msg(chip->dev, |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 968 | usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR, |
| 969 | USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, |
| 970 | validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), |
| 971 | value, val_len); |
Takashi Iwai | 888ea7d | 2012-10-15 12:40:37 +0200 | [diff] [blame] | 972 | up_read(&mixer->chip->shutdown_rwsem); |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 973 | if (err < 0) |
| 974 | return err; |
| 975 | |
| 976 | pval->cached_value = new_val; |
| 977 | pval->is_cached = 1; |
| 978 | changed = 1; |
| 979 | } |
| 980 | |
| 981 | return changed; |
| 982 | } |
| 983 | |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 984 | static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer, |
| 985 | int validx, int bUnitID) |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 986 | { |
| 987 | static struct snd_kcontrol_new template = { |
| 988 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 989 | .name = "Effect Program Switch", |
| 990 | .index = 0, |
| 991 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, |
| 992 | .info = snd_ftu_eff_switch_info, |
| 993 | .get = snd_ftu_eff_switch_get, |
| 994 | .put = snd_ftu_eff_switch_put |
| 995 | }; |
| 996 | |
| 997 | int err; |
| 998 | struct snd_kcontrol *kctl; |
| 999 | struct snd_ftu_eff_switch_priv_val *pval; |
| 1000 | |
| 1001 | pval = kzalloc(sizeof(*pval), GFP_KERNEL); |
| 1002 | if (!pval) |
| 1003 | return -ENOMEM; |
| 1004 | |
| 1005 | pval->cached_value = 0; |
| 1006 | pval->is_cached = 0; |
| 1007 | pval->mixer = mixer; |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 1008 | pval->bUnitID = bUnitID; |
| 1009 | pval->validx = validx; |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 1010 | |
| 1011 | template.private_value = (unsigned long) pval; |
| 1012 | kctl = snd_ctl_new1(&template, mixer->chip); |
| 1013 | if (!kctl) { |
| 1014 | kfree(pval); |
| 1015 | return -ENOMEM; |
| 1016 | } |
| 1017 | |
| 1018 | err = snd_ctl_add(mixer->chip->card, kctl); |
| 1019 | if (err < 0) |
| 1020 | return err; |
| 1021 | |
| 1022 | return 0; |
| 1023 | } |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1024 | |
Felix Homann | cfe8f97 | 2012-04-23 20:24:26 +0200 | [diff] [blame] | 1025 | /* Create volume controls for FTU devices*/ |
| 1026 | static int snd_ftu_create_volume_ctls(struct usb_mixer_interface *mixer) |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1027 | { |
| 1028 | char name[64]; |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1029 | unsigned int control, cmask; |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1030 | int in, out, err; |
| 1031 | |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1032 | const unsigned int id = 5; |
| 1033 | const int val_type = USB_MIXER_S16; |
| 1034 | |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1035 | for (out = 0; out < 8; out++) { |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1036 | control = out + 1; |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1037 | for (in = 0; in < 8; in++) { |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1038 | cmask = 1 << in; |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1039 | snprintf(name, sizeof(name), |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1040 | "AIn%d - Out%d Capture Volume", |
| 1041 | in + 1, out + 1); |
| 1042 | err = snd_create_std_mono_ctl(mixer, id, control, |
| 1043 | cmask, val_type, name, |
Felix Homann | 25ee7ef | 2012-04-23 20:24:25 +0200 | [diff] [blame] | 1044 | &snd_usb_mixer_vol_tlv); |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1045 | if (err < 0) |
| 1046 | return err; |
| 1047 | } |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1048 | for (in = 8; in < 16; in++) { |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1049 | cmask = 1 << in; |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1050 | snprintf(name, sizeof(name), |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1051 | "DIn%d - Out%d Playback Volume", |
| 1052 | in - 7, out + 1); |
| 1053 | err = snd_create_std_mono_ctl(mixer, id, control, |
| 1054 | cmask, val_type, name, |
Felix Homann | 25ee7ef | 2012-04-23 20:24:25 +0200 | [diff] [blame] | 1055 | &snd_usb_mixer_vol_tlv); |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1056 | if (err < 0) |
| 1057 | return err; |
| 1058 | } |
| 1059 | } |
| 1060 | |
| 1061 | return 0; |
| 1062 | } |
| 1063 | |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 1064 | /* This control needs a volume quirk, see mixer.c */ |
| 1065 | static int snd_ftu_create_effect_volume_ctl(struct usb_mixer_interface *mixer) |
| 1066 | { |
| 1067 | static const char name[] = "Effect Volume"; |
| 1068 | const unsigned int id = 6; |
| 1069 | const int val_type = USB_MIXER_U8; |
| 1070 | const unsigned int control = 2; |
| 1071 | const unsigned int cmask = 0; |
| 1072 | |
| 1073 | return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type, |
| 1074 | name, snd_usb_mixer_vol_tlv); |
| 1075 | } |
| 1076 | |
| 1077 | /* This control needs a volume quirk, see mixer.c */ |
| 1078 | static int snd_ftu_create_effect_duration_ctl(struct usb_mixer_interface *mixer) |
| 1079 | { |
| 1080 | static const char name[] = "Effect Duration"; |
| 1081 | const unsigned int id = 6; |
| 1082 | const int val_type = USB_MIXER_S16; |
| 1083 | const unsigned int control = 3; |
| 1084 | const unsigned int cmask = 0; |
| 1085 | |
| 1086 | return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type, |
| 1087 | name, snd_usb_mixer_vol_tlv); |
| 1088 | } |
| 1089 | |
| 1090 | /* This control needs a volume quirk, see mixer.c */ |
| 1091 | static int snd_ftu_create_effect_feedback_ctl(struct usb_mixer_interface *mixer) |
| 1092 | { |
| 1093 | static const char name[] = "Effect Feedback Volume"; |
| 1094 | const unsigned int id = 6; |
| 1095 | const int val_type = USB_MIXER_U8; |
| 1096 | const unsigned int control = 4; |
| 1097 | const unsigned int cmask = 0; |
| 1098 | |
| 1099 | return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type, |
| 1100 | name, NULL); |
| 1101 | } |
| 1102 | |
| 1103 | static int snd_ftu_create_effect_return_ctls(struct usb_mixer_interface *mixer) |
| 1104 | { |
| 1105 | unsigned int cmask; |
| 1106 | int err, ch; |
| 1107 | char name[48]; |
| 1108 | |
| 1109 | const unsigned int id = 7; |
| 1110 | const int val_type = USB_MIXER_S16; |
| 1111 | const unsigned int control = 7; |
| 1112 | |
| 1113 | for (ch = 0; ch < 4; ++ch) { |
| 1114 | cmask = 1 << ch; |
| 1115 | snprintf(name, sizeof(name), |
| 1116 | "Effect Return %d Volume", ch + 1); |
| 1117 | err = snd_create_std_mono_ctl(mixer, id, control, |
| 1118 | cmask, val_type, name, |
| 1119 | snd_usb_mixer_vol_tlv); |
| 1120 | if (err < 0) |
| 1121 | return err; |
| 1122 | } |
| 1123 | |
| 1124 | return 0; |
| 1125 | } |
| 1126 | |
| 1127 | static int snd_ftu_create_effect_send_ctls(struct usb_mixer_interface *mixer) |
| 1128 | { |
| 1129 | unsigned int cmask; |
| 1130 | int err, ch; |
| 1131 | char name[48]; |
| 1132 | |
| 1133 | const unsigned int id = 5; |
| 1134 | const int val_type = USB_MIXER_S16; |
| 1135 | const unsigned int control = 9; |
| 1136 | |
| 1137 | for (ch = 0; ch < 8; ++ch) { |
| 1138 | cmask = 1 << ch; |
| 1139 | snprintf(name, sizeof(name), |
| 1140 | "Effect Send AIn%d Volume", ch + 1); |
| 1141 | err = snd_create_std_mono_ctl(mixer, id, control, cmask, |
| 1142 | val_type, name, |
| 1143 | snd_usb_mixer_vol_tlv); |
| 1144 | if (err < 0) |
| 1145 | return err; |
| 1146 | } |
| 1147 | for (ch = 8; ch < 16; ++ch) { |
| 1148 | cmask = 1 << ch; |
| 1149 | snprintf(name, sizeof(name), |
| 1150 | "Effect Send DIn%d Volume", ch - 7); |
| 1151 | err = snd_create_std_mono_ctl(mixer, id, control, cmask, |
| 1152 | val_type, name, |
| 1153 | snd_usb_mixer_vol_tlv); |
| 1154 | if (err < 0) |
| 1155 | return err; |
| 1156 | } |
| 1157 | return 0; |
| 1158 | } |
| 1159 | |
Felix Homann | cfe8f97 | 2012-04-23 20:24:26 +0200 | [diff] [blame] | 1160 | static int snd_ftu_create_mixer(struct usb_mixer_interface *mixer) |
Mark Hills | 7536c30 | 2012-04-14 17:19:24 +0100 | [diff] [blame] | 1161 | { |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1162 | int err; |
Mark Hills | 7536c30 | 2012-04-14 17:19:24 +0100 | [diff] [blame] | 1163 | |
Felix Homann | cfe8f97 | 2012-04-23 20:24:26 +0200 | [diff] [blame] | 1164 | err = snd_ftu_create_volume_ctls(mixer); |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1165 | if (err < 0) |
| 1166 | return err; |
Mark Hills | 7536c30 | 2012-04-14 17:19:24 +0100 | [diff] [blame] | 1167 | |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 1168 | err = snd_ftu_create_effect_switch(mixer, 1, 6); |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 1169 | if (err < 0) |
| 1170 | return err; |
Eldad Zack | d847ce0 | 2012-11-28 23:55:37 +0100 | [diff] [blame] | 1171 | |
Felix Homann | d34bf14 | 2012-04-23 20:24:27 +0200 | [diff] [blame] | 1172 | err = snd_ftu_create_effect_volume_ctl(mixer); |
| 1173 | if (err < 0) |
| 1174 | return err; |
| 1175 | |
| 1176 | err = snd_ftu_create_effect_duration_ctl(mixer); |
| 1177 | if (err < 0) |
| 1178 | return err; |
| 1179 | |
| 1180 | err = snd_ftu_create_effect_feedback_ctl(mixer); |
| 1181 | if (err < 0) |
| 1182 | return err; |
| 1183 | |
| 1184 | err = snd_ftu_create_effect_return_ctls(mixer); |
| 1185 | if (err < 0) |
| 1186 | return err; |
| 1187 | |
| 1188 | err = snd_ftu_create_effect_send_ctls(mixer); |
| 1189 | if (err < 0) |
| 1190 | return err; |
| 1191 | |
Felix Homann | 8a4d1d3 | 2012-04-23 20:24:23 +0200 | [diff] [blame] | 1192 | return 0; |
Mark Hills | 7536c30 | 2012-04-14 17:19:24 +0100 | [diff] [blame] | 1193 | } |
| 1194 | |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1195 | void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, |
| 1196 | unsigned char samplerate_id) |
| 1197 | { |
| 1198 | struct usb_mixer_interface *mixer; |
| 1199 | struct usb_mixer_elem_info *cval; |
| 1200 | int unitid = 12; /* SamleRate ExtensionUnit ID */ |
| 1201 | |
| 1202 | list_for_each_entry(mixer, &chip->mixer_list, list) { |
| 1203 | cval = mixer->id_elems[unitid]; |
| 1204 | if (cval) { |
| 1205 | snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, |
| 1206 | cval->control << 8, |
| 1207 | samplerate_id); |
| 1208 | snd_usb_mixer_notify_id(mixer, unitid); |
| 1209 | } |
| 1210 | break; |
| 1211 | } |
| 1212 | } |
| 1213 | |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1214 | /* M-Audio Fast Track C400/C600 */ |
| 1215 | /* C400/C600 volume controls, this control needs a volume quirk, see mixer.c */ |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1216 | static int snd_c400_create_vol_ctls(struct usb_mixer_interface *mixer) |
| 1217 | { |
| 1218 | char name[64]; |
| 1219 | unsigned int cmask, offset; |
| 1220 | int out, chan, err; |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1221 | int num_outs = 0; |
| 1222 | int num_ins = 0; |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1223 | |
| 1224 | const unsigned int id = 0x40; |
| 1225 | const int val_type = USB_MIXER_S16; |
| 1226 | const int control = 1; |
| 1227 | |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1228 | switch (mixer->chip->usb_id) { |
| 1229 | case USB_ID(0x0763, 0x2030): |
| 1230 | num_outs = 6; |
| 1231 | num_ins = 4; |
| 1232 | break; |
| 1233 | case USB_ID(0x0763, 0x2031): |
| 1234 | num_outs = 8; |
| 1235 | num_ins = 6; |
| 1236 | break; |
| 1237 | } |
| 1238 | |
| 1239 | for (chan = 0; chan < num_outs + num_ins; chan++) { |
| 1240 | for (out = 0; out < num_outs; out++) { |
| 1241 | if (chan < num_outs) { |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1242 | snprintf(name, sizeof(name), |
| 1243 | "PCM%d-Out%d Playback Volume", |
| 1244 | chan + 1, out + 1); |
| 1245 | } else { |
| 1246 | snprintf(name, sizeof(name), |
| 1247 | "In%d-Out%d Playback Volume", |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1248 | chan - num_outs + 1, out + 1); |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | cmask = (out == 0) ? 0 : 1 << (out - 1); |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1252 | offset = chan * num_outs; |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1253 | err = snd_create_std_mono_ctl_offset(mixer, id, control, |
| 1254 | cmask, val_type, offset, name, |
| 1255 | &snd_usb_mixer_vol_tlv); |
| 1256 | if (err < 0) |
| 1257 | return err; |
| 1258 | } |
| 1259 | } |
| 1260 | |
| 1261 | return 0; |
| 1262 | } |
| 1263 | |
| 1264 | /* This control needs a volume quirk, see mixer.c */ |
| 1265 | static int snd_c400_create_effect_volume_ctl(struct usb_mixer_interface *mixer) |
| 1266 | { |
| 1267 | static const char name[] = "Effect Volume"; |
| 1268 | const unsigned int id = 0x43; |
| 1269 | const int val_type = USB_MIXER_U8; |
| 1270 | const unsigned int control = 3; |
| 1271 | const unsigned int cmask = 0; |
| 1272 | |
| 1273 | return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type, |
| 1274 | name, snd_usb_mixer_vol_tlv); |
| 1275 | } |
| 1276 | |
| 1277 | /* This control needs a volume quirk, see mixer.c */ |
| 1278 | static int snd_c400_create_effect_duration_ctl(struct usb_mixer_interface *mixer) |
| 1279 | { |
| 1280 | static const char name[] = "Effect Duration"; |
| 1281 | const unsigned int id = 0x43; |
| 1282 | const int val_type = USB_MIXER_S16; |
| 1283 | const unsigned int control = 4; |
| 1284 | const unsigned int cmask = 0; |
| 1285 | |
| 1286 | return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type, |
| 1287 | name, snd_usb_mixer_vol_tlv); |
| 1288 | } |
| 1289 | |
| 1290 | /* This control needs a volume quirk, see mixer.c */ |
| 1291 | static int snd_c400_create_effect_feedback_ctl(struct usb_mixer_interface *mixer) |
| 1292 | { |
| 1293 | static const char name[] = "Effect Feedback Volume"; |
| 1294 | const unsigned int id = 0x43; |
| 1295 | const int val_type = USB_MIXER_U8; |
| 1296 | const unsigned int control = 5; |
| 1297 | const unsigned int cmask = 0; |
| 1298 | |
| 1299 | return snd_create_std_mono_ctl(mixer, id, control, cmask, val_type, |
| 1300 | name, NULL); |
| 1301 | } |
| 1302 | |
| 1303 | static int snd_c400_create_effect_vol_ctls(struct usb_mixer_interface *mixer) |
| 1304 | { |
| 1305 | char name[64]; |
| 1306 | unsigned int cmask; |
| 1307 | int chan, err; |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1308 | int num_outs = 0; |
| 1309 | int num_ins = 0; |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1310 | |
| 1311 | const unsigned int id = 0x42; |
| 1312 | const int val_type = USB_MIXER_S16; |
| 1313 | const int control = 1; |
| 1314 | |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1315 | switch (mixer->chip->usb_id) { |
| 1316 | case USB_ID(0x0763, 0x2030): |
| 1317 | num_outs = 6; |
| 1318 | num_ins = 4; |
| 1319 | break; |
| 1320 | case USB_ID(0x0763, 0x2031): |
| 1321 | num_outs = 8; |
| 1322 | num_ins = 6; |
| 1323 | break; |
| 1324 | } |
| 1325 | |
| 1326 | for (chan = 0; chan < num_outs + num_ins; chan++) { |
| 1327 | if (chan < num_outs) { |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1328 | snprintf(name, sizeof(name), |
| 1329 | "Effect Send DOut%d", |
| 1330 | chan + 1); |
| 1331 | } else { |
| 1332 | snprintf(name, sizeof(name), |
| 1333 | "Effect Send AIn%d", |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1334 | chan - num_outs + 1); |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | cmask = (chan == 0) ? 0 : 1 << (chan - 1); |
| 1338 | err = snd_create_std_mono_ctl(mixer, id, control, |
| 1339 | cmask, val_type, name, |
| 1340 | &snd_usb_mixer_vol_tlv); |
| 1341 | if (err < 0) |
| 1342 | return err; |
| 1343 | } |
| 1344 | |
| 1345 | return 0; |
| 1346 | } |
| 1347 | |
| 1348 | static int snd_c400_create_effect_ret_vol_ctls(struct usb_mixer_interface *mixer) |
| 1349 | { |
| 1350 | char name[64]; |
| 1351 | unsigned int cmask; |
| 1352 | int chan, err; |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1353 | int num_outs = 0; |
| 1354 | int offset = 0; |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1355 | |
| 1356 | const unsigned int id = 0x40; |
| 1357 | const int val_type = USB_MIXER_S16; |
| 1358 | const int control = 1; |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1359 | |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1360 | switch (mixer->chip->usb_id) { |
| 1361 | case USB_ID(0x0763, 0x2030): |
| 1362 | num_outs = 6; |
| 1363 | offset = 0x3c; |
| 1364 | /* { 0x3c, 0x43, 0x3e, 0x45, 0x40, 0x47 } */ |
| 1365 | break; |
| 1366 | case USB_ID(0x0763, 0x2031): |
| 1367 | num_outs = 8; |
| 1368 | offset = 0x70; |
| 1369 | /* { 0x70, 0x79, 0x72, 0x7b, 0x74, 0x7d, 0x76, 0x7f } */ |
| 1370 | break; |
| 1371 | } |
| 1372 | |
| 1373 | for (chan = 0; chan < num_outs; chan++) { |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1374 | snprintf(name, sizeof(name), |
| 1375 | "Effect Return %d", |
| 1376 | chan + 1); |
| 1377 | |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1378 | cmask = (chan == 0) ? 0 : |
| 1379 | 1 << (chan + (chan % 2) * num_outs - 1); |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1380 | err = snd_create_std_mono_ctl_offset(mixer, id, control, |
| 1381 | cmask, val_type, offset, name, |
| 1382 | &snd_usb_mixer_vol_tlv); |
| 1383 | if (err < 0) |
| 1384 | return err; |
| 1385 | } |
| 1386 | |
| 1387 | return 0; |
| 1388 | } |
| 1389 | |
| 1390 | static int snd_c400_create_mixer(struct usb_mixer_interface *mixer) |
| 1391 | { |
| 1392 | int err; |
| 1393 | |
| 1394 | err = snd_c400_create_vol_ctls(mixer); |
| 1395 | if (err < 0) |
| 1396 | return err; |
| 1397 | |
| 1398 | err = snd_c400_create_effect_vol_ctls(mixer); |
| 1399 | if (err < 0) |
| 1400 | return err; |
| 1401 | |
| 1402 | err = snd_c400_create_effect_ret_vol_ctls(mixer); |
| 1403 | if (err < 0) |
| 1404 | return err; |
| 1405 | |
| 1406 | err = snd_ftu_create_effect_switch(mixer, 2, 0x43); |
| 1407 | if (err < 0) |
| 1408 | return err; |
| 1409 | |
| 1410 | err = snd_c400_create_effect_volume_ctl(mixer); |
| 1411 | if (err < 0) |
| 1412 | return err; |
| 1413 | |
| 1414 | err = snd_c400_create_effect_duration_ctl(mixer); |
| 1415 | if (err < 0) |
| 1416 | return err; |
| 1417 | |
| 1418 | err = snd_c400_create_effect_feedback_ctl(mixer); |
| 1419 | if (err < 0) |
| 1420 | return err; |
| 1421 | |
| 1422 | return 0; |
| 1423 | } |
| 1424 | |
Mark Hills | b71dad18 | 2012-06-09 13:16:38 +0100 | [diff] [blame] | 1425 | /* |
| 1426 | * The mixer units for Ebox-44 are corrupt, and even where they |
| 1427 | * are valid they presents mono controls as L and R channels of |
| 1428 | * stereo. So we provide a good mixer here. |
| 1429 | */ |
Sachin Kamat | e8e7da2 | 2013-01-10 11:19:14 +0530 | [diff] [blame] | 1430 | static struct std_mono_table ebox44_table[] = { |
Mark Hills | 989b013 | 2012-06-09 13:16:39 +0100 | [diff] [blame] | 1431 | { |
| 1432 | .unitid = 4, |
| 1433 | .control = 1, |
| 1434 | .cmask = 0x0, |
| 1435 | .val_type = USB_MIXER_INV_BOOLEAN, |
| 1436 | .name = "Headphone Playback Switch" |
| 1437 | }, |
| 1438 | { |
| 1439 | .unitid = 4, |
| 1440 | .control = 2, |
| 1441 | .cmask = 0x1, |
| 1442 | .val_type = USB_MIXER_S16, |
| 1443 | .name = "Headphone A Mix Playback Volume" |
| 1444 | }, |
| 1445 | { |
| 1446 | .unitid = 4, |
| 1447 | .control = 2, |
| 1448 | .cmask = 0x2, |
| 1449 | .val_type = USB_MIXER_S16, |
| 1450 | .name = "Headphone B Mix Playback Volume" |
| 1451 | }, |
Mark Hills | b71dad18 | 2012-06-09 13:16:38 +0100 | [diff] [blame] | 1452 | |
Mark Hills | 989b013 | 2012-06-09 13:16:39 +0100 | [diff] [blame] | 1453 | { |
| 1454 | .unitid = 7, |
| 1455 | .control = 1, |
| 1456 | .cmask = 0x0, |
| 1457 | .val_type = USB_MIXER_INV_BOOLEAN, |
| 1458 | .name = "Output Playback Switch" |
| 1459 | }, |
| 1460 | { |
| 1461 | .unitid = 7, |
| 1462 | .control = 2, |
| 1463 | .cmask = 0x1, |
| 1464 | .val_type = USB_MIXER_S16, |
| 1465 | .name = "Output A Playback Volume" |
| 1466 | }, |
| 1467 | { |
| 1468 | .unitid = 7, |
| 1469 | .control = 2, |
| 1470 | .cmask = 0x2, |
| 1471 | .val_type = USB_MIXER_S16, |
| 1472 | .name = "Output B Playback Volume" |
| 1473 | }, |
Mark Hills | b71dad18 | 2012-06-09 13:16:38 +0100 | [diff] [blame] | 1474 | |
Mark Hills | 989b013 | 2012-06-09 13:16:39 +0100 | [diff] [blame] | 1475 | { |
| 1476 | .unitid = 10, |
| 1477 | .control = 1, |
| 1478 | .cmask = 0x0, |
| 1479 | .val_type = USB_MIXER_INV_BOOLEAN, |
| 1480 | .name = "Input Capture Switch" |
| 1481 | }, |
| 1482 | { |
| 1483 | .unitid = 10, |
| 1484 | .control = 2, |
| 1485 | .cmask = 0x1, |
| 1486 | .val_type = USB_MIXER_S16, |
| 1487 | .name = "Input A Capture Volume" |
| 1488 | }, |
| 1489 | { |
| 1490 | .unitid = 10, |
| 1491 | .control = 2, |
| 1492 | .cmask = 0x2, |
| 1493 | .val_type = USB_MIXER_S16, |
| 1494 | .name = "Input B Capture Volume" |
| 1495 | }, |
Mark Hills | b71dad18 | 2012-06-09 13:16:38 +0100 | [diff] [blame] | 1496 | |
Mark Hills | 989b013 | 2012-06-09 13:16:39 +0100 | [diff] [blame] | 1497 | {} |
Mark Hills | b71dad18 | 2012-06-09 13:16:38 +0100 | [diff] [blame] | 1498 | }; |
| 1499 | |
Przemek Rudy | 066624c | 2013-06-27 23:52:33 +0200 | [diff] [blame] | 1500 | /* Audio Advantage Micro II findings: |
| 1501 | * |
| 1502 | * Mapping spdif AES bits to vendor register.bit: |
| 1503 | * AES0: [0 0 0 0 2.3 2.2 2.1 2.0] - default 0x00 |
| 1504 | * AES1: [3.3 3.2.3.1.3.0 2.7 2.6 2.5 2.4] - default: 0x01 |
| 1505 | * AES2: [0 0 0 0 0 0 0 0] |
| 1506 | * AES3: [0 0 0 0 0 0 x 0] - 'x' bit is set basing on standard usb request |
| 1507 | * (UAC_EP_CS_ATTR_SAMPLE_RATE) for Audio Devices |
| 1508 | * |
| 1509 | * power on values: |
| 1510 | * r2: 0x10 |
| 1511 | * r3: 0x20 (b7 is zeroed just before playback (except IEC61937) and set |
| 1512 | * just after it to 0xa0, presumably it disables/mutes some analog |
| 1513 | * parts when there is no audio.) |
| 1514 | * r9: 0x28 |
| 1515 | * |
| 1516 | * Optical transmitter on/off: |
| 1517 | * vendor register.bit: 9.1 |
| 1518 | * 0 - on (0x28 register value) |
| 1519 | * 1 - off (0x2a register value) |
| 1520 | * |
| 1521 | */ |
| 1522 | static int snd_microii_spdif_info(struct snd_kcontrol *kcontrol, |
| 1523 | struct snd_ctl_elem_info *uinfo) |
| 1524 | { |
| 1525 | uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; |
| 1526 | uinfo->count = 1; |
| 1527 | return 0; |
| 1528 | } |
| 1529 | |
| 1530 | static int snd_microii_spdif_default_get(struct snd_kcontrol *kcontrol, |
| 1531 | struct snd_ctl_elem_value *ucontrol) |
| 1532 | { |
| 1533 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 1534 | int err; |
| 1535 | struct usb_interface *iface; |
| 1536 | struct usb_host_interface *alts; |
| 1537 | unsigned int ep; |
| 1538 | unsigned char data[3]; |
| 1539 | int rate; |
| 1540 | |
| 1541 | ucontrol->value.iec958.status[0] = kcontrol->private_value & 0xff; |
| 1542 | ucontrol->value.iec958.status[1] = (kcontrol->private_value >> 8) & 0xff; |
| 1543 | ucontrol->value.iec958.status[2] = 0x00; |
| 1544 | |
| 1545 | /* use known values for that card: interface#1 altsetting#1 */ |
| 1546 | iface = usb_ifnum_to_if(mixer->chip->dev, 1); |
| 1547 | alts = &iface->altsetting[1]; |
| 1548 | ep = get_endpoint(alts, 0)->bEndpointAddress; |
| 1549 | |
| 1550 | err = snd_usb_ctl_msg(mixer->chip->dev, |
| 1551 | usb_rcvctrlpipe(mixer->chip->dev, 0), |
| 1552 | UAC_GET_CUR, |
| 1553 | USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN, |
| 1554 | UAC_EP_CS_ATTR_SAMPLE_RATE << 8, |
| 1555 | ep, |
| 1556 | data, |
| 1557 | sizeof(data)); |
| 1558 | if (err < 0) |
| 1559 | goto end; |
| 1560 | |
| 1561 | rate = data[0] | (data[1] << 8) | (data[2] << 16); |
| 1562 | ucontrol->value.iec958.status[3] = (rate == 48000) ? |
| 1563 | IEC958_AES3_CON_FS_48000 : IEC958_AES3_CON_FS_44100; |
| 1564 | |
| 1565 | err = 0; |
| 1566 | end: |
| 1567 | return err; |
| 1568 | } |
| 1569 | |
| 1570 | static int snd_microii_spdif_default_put(struct snd_kcontrol *kcontrol, |
| 1571 | struct snd_ctl_elem_value *ucontrol) |
| 1572 | { |
| 1573 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 1574 | int err; |
| 1575 | u8 reg; |
| 1576 | unsigned long priv_backup = kcontrol->private_value; |
| 1577 | |
| 1578 | reg = ((ucontrol->value.iec958.status[1] & 0x0f) << 4) | |
| 1579 | (ucontrol->value.iec958.status[0] & 0x0f); |
| 1580 | err = snd_usb_ctl_msg(mixer->chip->dev, |
| 1581 | usb_sndctrlpipe(mixer->chip->dev, 0), |
| 1582 | UAC_SET_CUR, |
| 1583 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
| 1584 | reg, |
| 1585 | 2, |
| 1586 | NULL, |
| 1587 | 0); |
| 1588 | if (err < 0) |
| 1589 | goto end; |
| 1590 | |
| 1591 | kcontrol->private_value &= 0xfffff0f0; |
| 1592 | kcontrol->private_value |= (ucontrol->value.iec958.status[1] & 0x0f) << 8; |
| 1593 | kcontrol->private_value |= (ucontrol->value.iec958.status[0] & 0x0f); |
| 1594 | |
| 1595 | reg = (ucontrol->value.iec958.status[0] & IEC958_AES0_NONAUDIO) ? |
| 1596 | 0xa0 : 0x20; |
| 1597 | reg |= (ucontrol->value.iec958.status[1] >> 4) & 0x0f; |
| 1598 | err = snd_usb_ctl_msg(mixer->chip->dev, |
| 1599 | usb_sndctrlpipe(mixer->chip->dev, 0), |
| 1600 | UAC_SET_CUR, |
| 1601 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
| 1602 | reg, |
| 1603 | 3, |
| 1604 | NULL, |
| 1605 | 0); |
| 1606 | if (err < 0) |
| 1607 | goto end; |
| 1608 | |
| 1609 | kcontrol->private_value &= 0xffff0fff; |
| 1610 | kcontrol->private_value |= (ucontrol->value.iec958.status[1] & 0xf0) << 8; |
| 1611 | |
| 1612 | /* The frequency bits in AES3 cannot be set via register access. */ |
| 1613 | |
| 1614 | /* Silently ignore any bits from the request that cannot be set. */ |
| 1615 | |
| 1616 | err = (priv_backup != kcontrol->private_value); |
| 1617 | end: |
| 1618 | return err; |
| 1619 | } |
| 1620 | |
| 1621 | static int snd_microii_spdif_mask_get(struct snd_kcontrol *kcontrol, |
| 1622 | struct snd_ctl_elem_value *ucontrol) |
| 1623 | { |
| 1624 | ucontrol->value.iec958.status[0] = 0x0f; |
| 1625 | ucontrol->value.iec958.status[1] = 0xff; |
| 1626 | ucontrol->value.iec958.status[2] = 0x00; |
| 1627 | ucontrol->value.iec958.status[3] = 0x00; |
| 1628 | |
| 1629 | return 0; |
| 1630 | } |
| 1631 | |
| 1632 | static int snd_microii_spdif_switch_get(struct snd_kcontrol *kcontrol, |
| 1633 | struct snd_ctl_elem_value *ucontrol) |
| 1634 | { |
| 1635 | ucontrol->value.integer.value[0] = !(kcontrol->private_value & 0x02); |
| 1636 | |
| 1637 | return 0; |
| 1638 | } |
| 1639 | |
| 1640 | static int snd_microii_spdif_switch_put(struct snd_kcontrol *kcontrol, |
| 1641 | struct snd_ctl_elem_value *ucontrol) |
| 1642 | { |
| 1643 | struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); |
| 1644 | int err; |
| 1645 | u8 reg = ucontrol->value.integer.value[0] ? 0x28 : 0x2a; |
| 1646 | |
| 1647 | err = snd_usb_ctl_msg(mixer->chip->dev, |
| 1648 | usb_sndctrlpipe(mixer->chip->dev, 0), |
| 1649 | UAC_SET_CUR, |
| 1650 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, |
| 1651 | reg, |
| 1652 | 9, |
| 1653 | NULL, |
| 1654 | 0); |
| 1655 | |
| 1656 | if (!err) { |
| 1657 | err = (reg != (kcontrol->private_value & 0x0ff)); |
| 1658 | if (err) |
| 1659 | kcontrol->private_value = reg; |
| 1660 | } |
| 1661 | |
| 1662 | return err; |
| 1663 | } |
| 1664 | |
| 1665 | static struct snd_kcontrol_new snd_microii_mixer_spdif[] = { |
| 1666 | { |
| 1667 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
| 1668 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), |
| 1669 | .info = snd_microii_spdif_info, |
| 1670 | .get = snd_microii_spdif_default_get, |
| 1671 | .put = snd_microii_spdif_default_put, |
| 1672 | .private_value = 0x00000100UL,/* reset value */ |
| 1673 | }, |
| 1674 | { |
| 1675 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
| 1676 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
| 1677 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK), |
| 1678 | .info = snd_microii_spdif_info, |
| 1679 | .get = snd_microii_spdif_mask_get, |
| 1680 | }, |
| 1681 | { |
| 1682 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1683 | .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH), |
| 1684 | .info = snd_ctl_boolean_mono_info, |
| 1685 | .get = snd_microii_spdif_switch_get, |
| 1686 | .put = snd_microii_spdif_switch_put, |
| 1687 | .private_value = 0x00000028UL,/* reset value */ |
| 1688 | } |
| 1689 | }; |
| 1690 | |
| 1691 | static int snd_microii_controls_create(struct usb_mixer_interface *mixer) |
| 1692 | { |
| 1693 | int err, i; |
| 1694 | |
| 1695 | for (i = 0; i < ARRAY_SIZE(snd_microii_mixer_spdif); ++i) { |
| 1696 | err = snd_ctl_add(mixer->chip->card, |
| 1697 | snd_ctl_new1(&snd_microii_mixer_spdif[i], mixer)); |
| 1698 | if (err < 0) |
| 1699 | return err; |
| 1700 | } |
| 1701 | |
Mikulas Patocka | 18e4753 | 2013-12-05 14:32:43 -0500 | [diff] [blame] | 1702 | return 0; |
Przemek Rudy | 066624c | 2013-06-27 23:52:33 +0200 | [diff] [blame] | 1703 | } |
| 1704 | |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1705 | int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) |
| 1706 | { |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1707 | int err = 0; |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1708 | struct snd_info_entry *entry; |
| 1709 | |
| 1710 | if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0) |
| 1711 | return err; |
| 1712 | |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1713 | switch (mixer->chip->usb_id) { |
| 1714 | case USB_ID(0x041e, 0x3020): |
| 1715 | case USB_ID(0x041e, 0x3040): |
| 1716 | case USB_ID(0x041e, 0x3042): |
Mathieu Bouffard | 7cdd8d7 | 2011-05-18 17:09:17 +0200 | [diff] [blame] | 1717 | case USB_ID(0x041e, 0x30df): |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1718 | case USB_ID(0x041e, 0x3048): |
| 1719 | err = snd_audigy2nx_controls_create(mixer); |
| 1720 | if (err < 0) |
| 1721 | break; |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1722 | if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry)) |
| 1723 | snd_info_set_text_ops(entry, mixer, |
| 1724 | snd_audigy2nx_proc_read); |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1725 | break; |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1726 | |
Vasily Khoruzhick | 44832a7 | 2013-11-13 13:13:35 +0300 | [diff] [blame] | 1727 | /* EMU0204 */ |
| 1728 | case USB_ID(0x041e, 0x3f19): |
| 1729 | err = snd_emu0204_controls_create(mixer); |
| 1730 | if (err < 0) |
| 1731 | break; |
| 1732 | break; |
| 1733 | |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1734 | case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */ |
Matt Gruskin | e9a25e0 | 2013-02-09 12:56:35 -0500 | [diff] [blame] | 1735 | case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C400 */ |
Eldad Zack | 09d8e3a | 2012-11-28 23:55:40 +0100 | [diff] [blame] | 1736 | err = snd_c400_create_mixer(mixer); |
| 1737 | break; |
| 1738 | |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1739 | case USB_ID(0x0763, 0x2080): /* M-Audio Fast Track Ultra */ |
| 1740 | case USB_ID(0x0763, 0x2081): /* M-Audio Fast Track Ultra 8R */ |
Felix Homann | cfe8f97 | 2012-04-23 20:24:26 +0200 | [diff] [blame] | 1741 | err = snd_ftu_create_mixer(mixer); |
Daniel Mack | d5a0bf6cc | 2011-05-25 09:09:03 +0200 | [diff] [blame] | 1742 | break; |
| 1743 | |
Denis Washington | 1d31aff | 2012-12-11 11:38:32 +0100 | [diff] [blame] | 1744 | case USB_ID(0x0b05, 0x1739): /* ASUS Xonar U1 */ |
| 1745 | case USB_ID(0x0b05, 0x1743): /* ASUS Xonar U1 (2) */ |
| 1746 | case USB_ID(0x0b05, 0x17a0): /* ASUS Xonar U3 */ |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1747 | err = snd_xonar_u1_controls_create(mixer); |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1748 | break; |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1749 | |
Przemek Rudy | 066624c | 2013-06-27 23:52:33 +0200 | [diff] [blame] | 1750 | case USB_ID(0x0d8c, 0x0103): /* Audio Advantage Micro II */ |
| 1751 | err = snd_microii_controls_create(mixer); |
| 1752 | break; |
| 1753 | |
Damien Zammit | d497a82 | 2014-11-12 01:09:54 +1100 | [diff] [blame] | 1754 | case USB_ID(0x0dba, 0x1000): /* Digidesign Mbox 1 */ |
| 1755 | err = snd_mbox1_create_sync_switch(mixer); |
| 1756 | break; |
| 1757 | |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1758 | case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */ |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 1759 | err = snd_nativeinstruments_create_mixer(mixer, |
| 1760 | snd_nativeinstruments_ta6_mixers, |
| 1761 | ARRAY_SIZE(snd_nativeinstruments_ta6_mixers)); |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1762 | break; |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 1763 | |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1764 | case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */ |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 1765 | err = snd_nativeinstruments_create_mixer(mixer, |
| 1766 | snd_nativeinstruments_ta10_mixers, |
| 1767 | ARRAY_SIZE(snd_nativeinstruments_ta10_mixers)); |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1768 | break; |
Mark Hills | 7536c30 | 2012-04-14 17:19:24 +0100 | [diff] [blame] | 1769 | |
| 1770 | case USB_ID(0x200c, 0x1018): /* Electrix Ebox-44 */ |
Mark Hills | b71dad18 | 2012-06-09 13:16:38 +0100 | [diff] [blame] | 1771 | /* detection is disabled in mixer_maps.c */ |
| 1772 | err = snd_create_std_mono_table(mixer, ebox44_table); |
Mark Hills | 7536c30 | 2012-04-14 17:19:24 +0100 | [diff] [blame] | 1773 | break; |
Chris J Arges | 76b188c | 2014-11-12 12:07:02 -0600 | [diff] [blame^] | 1774 | |
| 1775 | case USB_ID(0x1235, 0x8012): /* Focusrite Scarlett 6i6 */ |
| 1776 | case USB_ID(0x1235, 0x8002): /* Focusrite Scarlett 8i6 */ |
| 1777 | case USB_ID(0x1235, 0x8004): /* Focusrite Scarlett 18i6 */ |
| 1778 | case USB_ID(0x1235, 0x8014): /* Focusrite Scarlett 18i8 */ |
| 1779 | case USB_ID(0x1235, 0x800c): /* Focusrite Scarlett 18i20 */ |
| 1780 | err = snd_scarlett_controls_create(mixer); |
| 1781 | break; |
Daniel Mack | 54a8c50 | 2011-02-11 11:08:06 +0000 | [diff] [blame] | 1782 | } |
| 1783 | |
Daniel Mack | 3347b26 | 2011-02-11 11:34:12 +0000 | [diff] [blame] | 1784 | return err; |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer, |
| 1788 | int unitid) |
| 1789 | { |
| 1790 | if (!mixer->rc_cfg) |
| 1791 | return; |
| 1792 | /* unit ids specific to Extigy/Audigy 2 NX: */ |
| 1793 | switch (unitid) { |
| 1794 | case 0: /* remote control */ |
| 1795 | mixer->rc_urb->dev = mixer->chip->dev; |
| 1796 | usb_submit_urb(mixer->rc_urb, GFP_ATOMIC); |
| 1797 | break; |
| 1798 | case 4: /* digital in jack */ |
| 1799 | case 7: /* line in jacks */ |
| 1800 | case 19: /* speaker out jacks */ |
| 1801 | case 20: /* headphones out jack */ |
| 1802 | break; |
| 1803 | /* live24ext: 4 = line-in jack */ |
| 1804 | case 3: /* hp-out jack (may actuate Mute) */ |
| 1805 | if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) || |
| 1806 | mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) |
| 1807 | snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id); |
| 1808 | break; |
| 1809 | default: |
Takashi Iwai | 0ba41d9 | 2014-02-26 13:02:17 +0100 | [diff] [blame] | 1810 | usb_audio_dbg(mixer->chip, "memory change in unknown unit %d\n", unitid); |
Daniel Mack | 7b1eda2 | 2010-03-11 21:13:22 +0100 | [diff] [blame] | 1811 | break; |
| 1812 | } |
| 1813 | } |
| 1814 | |