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