Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007, 2008 Karsten Wiese <fzu@wemgehoertderstaat.de> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| 7 | * option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software Foundation, |
| 16 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 17 | */ |
| 18 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> |
Daniel Mack | de48c7b | 2010-02-22 23:49:13 +0100 | [diff] [blame] | 20 | #include <linux/usb.h> |
| 21 | #include <linux/usb/audio.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 22 | #include <linux/module.h> |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 23 | #include <sound/core.h> |
| 24 | #include <sound/hwdep.h> |
| 25 | #include <sound/pcm.h> |
| 26 | #include <sound/initval.h> |
| 27 | #define MODNAME "US122L" |
| 28 | #include "usb_stream.c" |
| 29 | #include "../usbaudio.h" |
Daniel Mack | e577999 | 2010-03-04 19:46:13 +0100 | [diff] [blame] | 30 | #include "../midi.h" |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 31 | #include "us122l.h" |
| 32 | |
| 33 | MODULE_AUTHOR("Karsten Wiese <fzu@wemgehoertderstaat.de>"); |
| 34 | MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.5"); |
| 35 | MODULE_LICENSE("GPL"); |
| 36 | |
| 37 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ |
| 38 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ |
| 39 | /* Enable this card */ |
Rusty Russell | a67ff6a | 2011-12-15 13:49:36 +1030 | [diff] [blame] | 40 | static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 41 | |
| 42 | module_param_array(index, int, NULL, 0444); |
| 43 | MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS"."); |
| 44 | module_param_array(id, charp, NULL, 0444); |
| 45 | MODULE_PARM_DESC(id, "ID string for "NAME_ALLCAPS"."); |
| 46 | module_param_array(enable, bool, NULL, 0444); |
| 47 | MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS"."); |
| 48 | |
| 49 | static int snd_us122l_card_used[SNDRV_CARDS]; |
| 50 | |
| 51 | |
| 52 | static int us122l_create_usbmidi(struct snd_card *card) |
| 53 | { |
| 54 | static struct snd_usb_midi_endpoint_info quirk_data = { |
| 55 | .out_ep = 4, |
| 56 | .in_ep = 3, |
| 57 | .out_cables = 0x001, |
| 58 | .in_cables = 0x001 |
| 59 | }; |
| 60 | static struct snd_usb_audio_quirk quirk = { |
| 61 | .vendor_name = "US122L", |
| 62 | .product_name = NAME_ALLCAPS, |
| 63 | .ifnum = 1, |
| 64 | .type = QUIRK_MIDI_US122L, |
| 65 | .data = &quirk_data |
| 66 | }; |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 67 | struct usb_device *dev = US122L(card)->dev; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 68 | struct usb_interface *iface = usb_ifnum_to_if(dev, 1); |
| 69 | |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 70 | return snd_usbmidi_create(card, iface, |
| 71 | &US122L(card)->midi_list, &quirk); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 72 | } |
| 73 | |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 74 | static int us144_create_usbmidi(struct snd_card *card) |
| 75 | { |
| 76 | static struct snd_usb_midi_endpoint_info quirk_data = { |
| 77 | .out_ep = 4, |
| 78 | .in_ep = 3, |
| 79 | .out_cables = 0x001, |
| 80 | .in_cables = 0x001 |
| 81 | }; |
| 82 | static struct snd_usb_audio_quirk quirk = { |
| 83 | .vendor_name = "US144", |
| 84 | .product_name = NAME_ALLCAPS, |
| 85 | .ifnum = 0, |
| 86 | .type = QUIRK_MIDI_US122L, |
| 87 | .data = &quirk_data |
| 88 | }; |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 89 | struct usb_device *dev = US122L(card)->dev; |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 90 | struct usb_interface *iface = usb_ifnum_to_if(dev, 0); |
| 91 | |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 92 | return snd_usbmidi_create(card, iface, |
| 93 | &US122L(card)->midi_list, &quirk); |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 94 | } |
| 95 | |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 96 | /* |
| 97 | * Wrapper for usb_control_msg(). |
| 98 | * Allocates a temp buffer to prevent dmaing from/to the stack. |
| 99 | */ |
| 100 | static int us122l_ctl_msg(struct usb_device *dev, unsigned int pipe, |
| 101 | __u8 request, __u8 requesttype, |
| 102 | __u16 value, __u16 index, void *data, |
| 103 | __u16 size, int timeout) |
| 104 | { |
| 105 | int err; |
| 106 | void *buf = NULL; |
| 107 | |
| 108 | if (size > 0) { |
| 109 | buf = kmemdup(data, size, GFP_KERNEL); |
| 110 | if (!buf) |
| 111 | return -ENOMEM; |
| 112 | } |
| 113 | err = usb_control_msg(dev, pipe, request, requesttype, |
| 114 | value, index, buf, size, timeout); |
| 115 | if (size > 0) { |
| 116 | memcpy(data, buf, size); |
| 117 | kfree(buf); |
| 118 | } |
| 119 | return err; |
| 120 | } |
| 121 | |
| 122 | static void pt_info_set(struct usb_device *dev, u8 v) |
| 123 | { |
| 124 | int ret; |
| 125 | |
| 126 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
| 127 | 'I', |
| 128 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 129 | v, 0, NULL, 0, 1000); |
| 130 | snd_printdd(KERN_DEBUG "%i\n", ret); |
| 131 | } |
| 132 | |
| 133 | static void usb_stream_hwdep_vm_open(struct vm_area_struct *area) |
| 134 | { |
| 135 | struct us122l *us122l = area->vm_private_data; |
| 136 | atomic_inc(&us122l->mmap_count); |
| 137 | snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count)); |
| 138 | } |
| 139 | |
| 140 | static int usb_stream_hwdep_vm_fault(struct vm_area_struct *area, |
| 141 | struct vm_fault *vmf) |
| 142 | { |
| 143 | unsigned long offset; |
| 144 | struct page *page; |
| 145 | void *vaddr; |
| 146 | struct us122l *us122l = area->vm_private_data; |
| 147 | struct usb_stream *s; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 148 | |
| 149 | mutex_lock(&us122l->mutex); |
| 150 | s = us122l->sk.s; |
| 151 | if (!s) |
Li Zefan | 428ffb7 | 2008-10-15 10:07:23 +0800 | [diff] [blame] | 152 | goto unlock; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 153 | |
| 154 | offset = vmf->pgoff << PAGE_SHIFT; |
| 155 | if (offset < PAGE_ALIGN(s->read_size)) |
| 156 | vaddr = (char *)s + offset; |
| 157 | else { |
| 158 | offset -= PAGE_ALIGN(s->read_size); |
| 159 | if (offset >= PAGE_ALIGN(s->write_size)) |
Li Zefan | 428ffb7 | 2008-10-15 10:07:23 +0800 | [diff] [blame] | 160 | goto unlock; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 161 | |
| 162 | vaddr = us122l->sk.write_page + offset; |
| 163 | } |
| 164 | page = virt_to_page(vaddr); |
| 165 | |
| 166 | get_page(page); |
| 167 | mutex_unlock(&us122l->mutex); |
| 168 | |
| 169 | vmf->page = page; |
Li Zefan | 428ffb7 | 2008-10-15 10:07:23 +0800 | [diff] [blame] | 170 | |
| 171 | return 0; |
| 172 | unlock: |
| 173 | mutex_unlock(&us122l->mutex); |
| 174 | return VM_FAULT_SIGBUS; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | static void usb_stream_hwdep_vm_close(struct vm_area_struct *area) |
| 178 | { |
| 179 | struct us122l *us122l = area->vm_private_data; |
| 180 | atomic_dec(&us122l->mmap_count); |
| 181 | snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count)); |
| 182 | } |
| 183 | |
Alexey Dobriyan | f0f37e2 | 2009-09-27 22:29:37 +0400 | [diff] [blame] | 184 | static const struct vm_operations_struct usb_stream_hwdep_vm_ops = { |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 185 | .open = usb_stream_hwdep_vm_open, |
| 186 | .fault = usb_stream_hwdep_vm_fault, |
| 187 | .close = usb_stream_hwdep_vm_close, |
| 188 | }; |
| 189 | |
| 190 | |
| 191 | static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file) |
| 192 | { |
| 193 | struct us122l *us122l = hw->private_data; |
| 194 | struct usb_interface *iface; |
| 195 | snd_printdd(KERN_DEBUG "%p %p\n", hw, file); |
| 196 | if (hw->used >= 2) |
| 197 | return -EBUSY; |
| 198 | |
| 199 | if (!us122l->first) |
| 200 | us122l->first = file; |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 201 | |
Tobias Hansen | 2b6f6c0 | 2009-12-07 19:08:19 +0100 | [diff] [blame] | 202 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || |
| 203 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 204 | iface = usb_ifnum_to_if(us122l->dev, 0); |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 205 | usb_autopm_get_interface(iface); |
| 206 | } |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 207 | iface = usb_ifnum_to_if(us122l->dev, 1); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 208 | usb_autopm_get_interface(iface); |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file) |
| 213 | { |
| 214 | struct us122l *us122l = hw->private_data; |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 215 | struct usb_interface *iface; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 216 | snd_printdd(KERN_DEBUG "%p %p\n", hw, file); |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 217 | |
Tobias Hansen | 2b6f6c0 | 2009-12-07 19:08:19 +0100 | [diff] [blame] | 218 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || |
| 219 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 220 | iface = usb_ifnum_to_if(us122l->dev, 0); |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 221 | usb_autopm_put_interface(iface); |
| 222 | } |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 223 | iface = usb_ifnum_to_if(us122l->dev, 1); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 224 | usb_autopm_put_interface(iface); |
| 225 | if (us122l->first == file) |
| 226 | us122l->first = NULL; |
| 227 | mutex_lock(&us122l->mutex); |
| 228 | if (us122l->master == file) |
| 229 | us122l->master = us122l->slave; |
| 230 | |
| 231 | us122l->slave = NULL; |
| 232 | mutex_unlock(&us122l->mutex); |
| 233 | return 0; |
| 234 | } |
| 235 | |
| 236 | static int usb_stream_hwdep_mmap(struct snd_hwdep *hw, |
| 237 | struct file *filp, struct vm_area_struct *area) |
| 238 | { |
| 239 | unsigned long size = area->vm_end - area->vm_start; |
| 240 | struct us122l *us122l = hw->private_data; |
| 241 | unsigned long offset; |
| 242 | struct usb_stream *s; |
| 243 | int err = 0; |
| 244 | bool read; |
| 245 | |
| 246 | offset = area->vm_pgoff << PAGE_SHIFT; |
| 247 | mutex_lock(&us122l->mutex); |
| 248 | s = us122l->sk.s; |
| 249 | read = offset < s->read_size; |
| 250 | if (read && area->vm_flags & VM_WRITE) { |
| 251 | err = -EPERM; |
| 252 | goto out; |
| 253 | } |
| 254 | snd_printdd(KERN_DEBUG "%lu %u\n", size, |
| 255 | read ? s->read_size : s->write_size); |
| 256 | /* if userspace tries to mmap beyond end of our buffer, fail */ |
| 257 | if (size > PAGE_ALIGN(read ? s->read_size : s->write_size)) { |
| 258 | snd_printk(KERN_WARNING "%lu > %u\n", size, |
| 259 | read ? s->read_size : s->write_size); |
| 260 | err = -EINVAL; |
| 261 | goto out; |
| 262 | } |
| 263 | |
| 264 | area->vm_ops = &usb_stream_hwdep_vm_ops; |
Takashi Iwai | ac536a8 | 2013-10-14 16:02:15 +0200 | [diff] [blame] | 265 | area->vm_flags |= VM_DONTDUMP; |
| 266 | if (!read) |
| 267 | area->vm_flags |= VM_DONTEXPAND; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 268 | area->vm_private_data = us122l; |
| 269 | atomic_inc(&us122l->mmap_count); |
| 270 | out: |
| 271 | mutex_unlock(&us122l->mutex); |
| 272 | return err; |
| 273 | } |
| 274 | |
| 275 | static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw, |
| 276 | struct file *file, poll_table *wait) |
| 277 | { |
| 278 | struct us122l *us122l = hw->private_data; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 279 | unsigned *polled; |
| 280 | unsigned int mask; |
| 281 | |
| 282 | poll_wait(file, &us122l->sk.sleep, wait); |
| 283 | |
Karsten Wiese | cdce2db | 2011-01-04 01:20:37 +0100 | [diff] [blame] | 284 | mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR; |
| 285 | if (mutex_trylock(&us122l->mutex)) { |
| 286 | struct usb_stream *s = us122l->sk.s; |
| 287 | if (s && s->state == usb_stream_ready) { |
| 288 | if (us122l->first == file) |
| 289 | polled = &s->periods_polled; |
| 290 | else |
| 291 | polled = &us122l->second_periods_polled; |
| 292 | if (*polled != s->periods_done) { |
| 293 | *polled = s->periods_done; |
| 294 | mask = POLLIN | POLLOUT | POLLWRNORM; |
| 295 | } else |
| 296 | mask = 0; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 297 | } |
Karsten Wiese | cdce2db | 2011-01-04 01:20:37 +0100 | [diff] [blame] | 298 | mutex_unlock(&us122l->mutex); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 299 | } |
| 300 | return mask; |
| 301 | } |
| 302 | |
| 303 | static void us122l_stop(struct us122l *us122l) |
| 304 | { |
| 305 | struct list_head *p; |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 306 | list_for_each(p, &us122l->midi_list) |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 307 | snd_usbmidi_input_stop(p); |
| 308 | |
| 309 | usb_stream_stop(&us122l->sk); |
| 310 | usb_stream_free(&us122l->sk); |
| 311 | } |
| 312 | |
| 313 | static int us122l_set_sample_rate(struct usb_device *dev, int rate) |
| 314 | { |
| 315 | unsigned int ep = 0x81; |
| 316 | unsigned char data[3]; |
| 317 | int err; |
| 318 | |
| 319 | data[0] = rate; |
| 320 | data[1] = rate >> 8; |
| 321 | data[2] = rate >> 16; |
Daniel Mack | de48c7b | 2010-02-22 23:49:13 +0100 | [diff] [blame] | 322 | err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 323 | USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, |
Daniel Mack | de48c7b | 2010-02-22 23:49:13 +0100 | [diff] [blame] | 324 | UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 325 | if (err < 0) |
| 326 | snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", |
| 327 | dev->devnum, rate, ep); |
| 328 | return err; |
| 329 | } |
| 330 | |
| 331 | static bool us122l_start(struct us122l *us122l, |
| 332 | unsigned rate, unsigned period_frames) |
| 333 | { |
| 334 | struct list_head *p; |
| 335 | int err; |
| 336 | unsigned use_packsize = 0; |
| 337 | bool success = false; |
| 338 | |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 339 | if (us122l->dev->speed == USB_SPEED_HIGH) { |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 340 | /* The us-122l's descriptor defaults to iso max_packsize 78, |
| 341 | which isn't needed for samplerates <= 48000. |
| 342 | Lets save some memory: |
| 343 | */ |
| 344 | switch (rate) { |
| 345 | case 44100: |
| 346 | use_packsize = 36; |
| 347 | break; |
| 348 | case 48000: |
| 349 | use_packsize = 42; |
| 350 | break; |
| 351 | case 88200: |
| 352 | use_packsize = 72; |
| 353 | break; |
| 354 | } |
| 355 | } |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 356 | if (!usb_stream_new(&us122l->sk, us122l->dev, 1, 2, |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 357 | rate, use_packsize, period_frames, 6)) |
| 358 | goto out; |
| 359 | |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 360 | err = us122l_set_sample_rate(us122l->dev, rate); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 361 | if (err < 0) { |
| 362 | us122l_stop(us122l); |
| 363 | snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); |
| 364 | goto out; |
| 365 | } |
| 366 | err = usb_stream_start(&us122l->sk); |
| 367 | if (err < 0) { |
| 368 | us122l_stop(us122l); |
| 369 | snd_printk(KERN_ERR "us122l_start error %i \n", err); |
| 370 | goto out; |
| 371 | } |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 372 | list_for_each(p, &us122l->midi_list) |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 373 | snd_usbmidi_input_start(p); |
| 374 | success = true; |
| 375 | out: |
| 376 | return success; |
| 377 | } |
| 378 | |
| 379 | static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, |
| 380 | unsigned cmd, unsigned long arg) |
| 381 | { |
| 382 | struct usb_stream_config *cfg; |
| 383 | struct us122l *us122l = hw->private_data; |
Karsten Wiese | cdce2db | 2011-01-04 01:20:37 +0100 | [diff] [blame] | 384 | struct usb_stream *s; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 385 | unsigned min_period_frames; |
| 386 | int err = 0; |
| 387 | bool high_speed; |
| 388 | |
| 389 | if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) |
| 390 | return -ENOTTY; |
| 391 | |
Li Zefan | 85385c1 | 2009-04-10 09:43:59 +0800 | [diff] [blame] | 392 | cfg = memdup_user((void *)arg, sizeof(*cfg)); |
| 393 | if (IS_ERR(cfg)) |
| 394 | return PTR_ERR(cfg); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 395 | |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 396 | if (cfg->version != USB_STREAM_INTERFACE_VERSION) { |
| 397 | err = -ENXIO; |
| 398 | goto free; |
| 399 | } |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 400 | high_speed = us122l->dev->speed == USB_SPEED_HIGH; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 401 | if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 && |
| 402 | (!high_speed || |
| 403 | (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) || |
| 404 | cfg->frame_size != 6 || |
| 405 | cfg->period_frames > 0x3000) { |
| 406 | err = -EINVAL; |
| 407 | goto free; |
| 408 | } |
| 409 | switch (cfg->sample_rate) { |
| 410 | case 44100: |
| 411 | min_period_frames = 48; |
| 412 | break; |
| 413 | case 48000: |
| 414 | min_period_frames = 52; |
| 415 | break; |
| 416 | default: |
| 417 | min_period_frames = 104; |
| 418 | break; |
| 419 | } |
| 420 | if (!high_speed) |
| 421 | min_period_frames <<= 1; |
| 422 | if (cfg->period_frames < min_period_frames) { |
| 423 | err = -EINVAL; |
| 424 | goto free; |
| 425 | } |
| 426 | |
| 427 | snd_power_wait(hw->card, SNDRV_CTL_POWER_D0); |
| 428 | |
| 429 | mutex_lock(&us122l->mutex); |
Karsten Wiese | cdce2db | 2011-01-04 01:20:37 +0100 | [diff] [blame] | 430 | s = us122l->sk.s; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 431 | if (!us122l->master) |
| 432 | us122l->master = file; |
| 433 | else if (us122l->master != file) { |
Karsten Wiese | cdce2db | 2011-01-04 01:20:37 +0100 | [diff] [blame] | 434 | if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg))) { |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 435 | err = -EIO; |
| 436 | goto unlock; |
| 437 | } |
| 438 | us122l->slave = file; |
| 439 | } |
Karsten Wiese | cdce2db | 2011-01-04 01:20:37 +0100 | [diff] [blame] | 440 | if (!s || memcmp(cfg, &s->cfg, sizeof(*cfg)) || |
| 441 | s->state == usb_stream_xrun) { |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 442 | us122l_stop(us122l); |
| 443 | if (!us122l_start(us122l, cfg->sample_rate, cfg->period_frames)) |
| 444 | err = -EIO; |
| 445 | else |
| 446 | err = 1; |
| 447 | } |
| 448 | unlock: |
| 449 | mutex_unlock(&us122l->mutex); |
| 450 | free: |
| 451 | kfree(cfg); |
Karsten Wiese | cdce2db | 2011-01-04 01:20:37 +0100 | [diff] [blame] | 452 | wake_up_all(&us122l->sk.sleep); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 453 | return err; |
| 454 | } |
| 455 | |
| 456 | #define SND_USB_STREAM_ID "USB STREAM" |
| 457 | static int usb_stream_hwdep_new(struct snd_card *card) |
| 458 | { |
| 459 | int err; |
| 460 | struct snd_hwdep *hw; |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 461 | struct usb_device *dev = US122L(card)->dev; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 462 | |
| 463 | err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw); |
| 464 | if (err < 0) |
| 465 | return err; |
| 466 | |
| 467 | hw->iface = SNDRV_HWDEP_IFACE_USB_STREAM; |
| 468 | hw->private_data = US122L(card); |
| 469 | hw->ops.open = usb_stream_hwdep_open; |
| 470 | hw->ops.release = usb_stream_hwdep_release; |
| 471 | hw->ops.ioctl = usb_stream_hwdep_ioctl; |
| 472 | hw->ops.ioctl_compat = usb_stream_hwdep_ioctl; |
| 473 | hw->ops.mmap = usb_stream_hwdep_mmap; |
| 474 | hw->ops.poll = usb_stream_hwdep_poll; |
| 475 | |
| 476 | sprintf(hw->name, "/proc/bus/usb/%03d/%03d/hwdeppcm", |
| 477 | dev->bus->busnum, dev->devnum); |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | |
| 482 | static bool us122l_create_card(struct snd_card *card) |
| 483 | { |
| 484 | int err; |
| 485 | struct us122l *us122l = US122L(card); |
| 486 | |
Tobias Hansen | 2b6f6c0 | 2009-12-07 19:08:19 +0100 | [diff] [blame] | 487 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || |
| 488 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 489 | err = usb_set_interface(us122l->dev, 0, 1); |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 490 | if (err) { |
| 491 | snd_printk(KERN_ERR "usb_set_interface error \n"); |
| 492 | return false; |
| 493 | } |
| 494 | } |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 495 | err = usb_set_interface(us122l->dev, 1, 1); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 496 | if (err) { |
| 497 | snd_printk(KERN_ERR "usb_set_interface error \n"); |
| 498 | return false; |
| 499 | } |
| 500 | |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 501 | pt_info_set(us122l->dev, 0x11); |
| 502 | pt_info_set(us122l->dev, 0x10); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 503 | |
| 504 | if (!us122l_start(us122l, 44100, 256)) |
| 505 | return false; |
| 506 | |
Tobias Hansen | 2b6f6c0 | 2009-12-07 19:08:19 +0100 | [diff] [blame] | 507 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || |
| 508 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 509 | err = us144_create_usbmidi(card); |
| 510 | else |
| 511 | err = us122l_create_usbmidi(card); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 512 | if (err < 0) { |
| 513 | snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err); |
| 514 | us122l_stop(us122l); |
| 515 | return false; |
| 516 | } |
| 517 | err = usb_stream_hwdep_new(card); |
| 518 | if (err < 0) { |
| 519 | /* release the midi resources */ |
| 520 | struct list_head *p; |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 521 | list_for_each(p, &us122l->midi_list) |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 522 | snd_usbmidi_disconnect(p); |
| 523 | |
| 524 | us122l_stop(us122l); |
| 525 | return false; |
| 526 | } |
| 527 | return true; |
| 528 | } |
| 529 | |
Karsten Wiese | 5d4af1b | 2009-04-20 13:01:21 +0200 | [diff] [blame] | 530 | static void snd_us122l_free(struct snd_card *card) |
| 531 | { |
| 532 | struct us122l *us122l = US122L(card); |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 533 | int index = us122l->card_index; |
Karsten Wiese | 5d4af1b | 2009-04-20 13:01:21 +0200 | [diff] [blame] | 534 | if (index >= 0 && index < SNDRV_CARDS) |
| 535 | snd_us122l_card_used[index] = 0; |
| 536 | } |
| 537 | |
Takashi Iwai | 874b8d4 | 2014-01-29 14:22:20 +0100 | [diff] [blame] | 538 | static int usx2y_create_card(struct usb_device *device, |
| 539 | struct usb_interface *intf, |
| 540 | struct snd_card **cardp) |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 541 | { |
| 542 | int dev; |
| 543 | struct snd_card *card; |
Takashi Iwai | bd7dd77 | 2008-12-28 16:45:02 +0100 | [diff] [blame] | 544 | int err; |
| 545 | |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 546 | for (dev = 0; dev < SNDRV_CARDS; ++dev) |
| 547 | if (enable[dev] && !snd_us122l_card_used[dev]) |
| 548 | break; |
| 549 | if (dev >= SNDRV_CARDS) |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 550 | return -ENODEV; |
Takashi Iwai | 874b8d4 | 2014-01-29 14:22:20 +0100 | [diff] [blame] | 551 | err = snd_card_new(&intf->dev, index[dev], id[dev], THIS_MODULE, |
| 552 | sizeof(struct us122l), &card); |
Takashi Iwai | bd7dd77 | 2008-12-28 16:45:02 +0100 | [diff] [blame] | 553 | if (err < 0) |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 554 | return err; |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 555 | snd_us122l_card_used[US122L(card)->card_index = dev] = 1; |
Karsten Wiese | 5d4af1b | 2009-04-20 13:01:21 +0200 | [diff] [blame] | 556 | card->private_free = snd_us122l_free; |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 557 | US122L(card)->dev = device; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 558 | mutex_init(&US122L(card)->mutex); |
| 559 | init_waitqueue_head(&US122L(card)->sk.sleep); |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 560 | INIT_LIST_HEAD(&US122L(card)->midi_list); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 561 | strcpy(card->driver, "USB "NAME_ALLCAPS""); |
| 562 | sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); |
| 563 | sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", |
| 564 | card->shortname, |
| 565 | le16_to_cpu(device->descriptor.idVendor), |
| 566 | le16_to_cpu(device->descriptor.idProduct), |
| 567 | 0, |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 568 | US122L(card)->dev->bus->busnum, |
| 569 | US122L(card)->dev->devnum |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 570 | ); |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 571 | *cardp = card; |
| 572 | return 0; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 573 | } |
| 574 | |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 575 | static int us122l_usb_probe(struct usb_interface *intf, |
| 576 | const struct usb_device_id *device_id, |
| 577 | struct snd_card **cardp) |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 578 | { |
| 579 | struct usb_device *device = interface_to_usbdev(intf); |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 580 | struct snd_card *card; |
| 581 | int err; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 582 | |
Takashi Iwai | 874b8d4 | 2014-01-29 14:22:20 +0100 | [diff] [blame] | 583 | err = usx2y_create_card(device, intf, &card); |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 584 | if (err < 0) |
| 585 | return err; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 586 | |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 587 | if (!us122l_create_card(card)) { |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 588 | snd_card_free(card); |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 589 | return -EINVAL; |
| 590 | } |
| 591 | |
| 592 | err = snd_card_register(card); |
| 593 | if (err < 0) { |
| 594 | snd_card_free(card); |
| 595 | return err; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 596 | } |
| 597 | |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 598 | usb_get_intf(usb_ifnum_to_if(device, 0)); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 599 | usb_get_dev(device); |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 600 | *cardp = card; |
| 601 | return 0; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | static int snd_us122l_probe(struct usb_interface *intf, |
| 605 | const struct usb_device_id *id) |
| 606 | { |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 607 | struct usb_device *device = interface_to_usbdev(intf); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 608 | struct snd_card *card; |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 609 | int err; |
| 610 | |
Tobias Hansen | 2b6f6c0 | 2009-12-07 19:08:19 +0100 | [diff] [blame] | 611 | if ((device->descriptor.idProduct == USB_ID_US144 || |
| 612 | device->descriptor.idProduct == USB_ID_US144MKII) |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 613 | && device->speed == USB_SPEED_HIGH) { |
| 614 | snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n"); |
Tobias Hansen | a688e48 | 2009-10-12 16:24:15 +0200 | [diff] [blame] | 615 | return -ENODEV; |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 616 | } |
| 617 | |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 618 | snd_printdd(KERN_DEBUG"%p:%i\n", |
| 619 | intf, intf->cur_altsetting->desc.bInterfaceNumber); |
| 620 | if (intf->cur_altsetting->desc.bInterfaceNumber != 1) |
| 621 | return 0; |
| 622 | |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 623 | err = us122l_usb_probe(usb_get_intf(intf), id, &card); |
| 624 | if (err < 0) { |
| 625 | usb_put_intf(intf); |
| 626 | return err; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 627 | } |
| 628 | |
Takashi Iwai | 51721f7 | 2008-12-28 16:55:08 +0100 | [diff] [blame] | 629 | usb_set_intfdata(intf, card); |
| 630 | return 0; |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | static void snd_us122l_disconnect(struct usb_interface *intf) |
| 634 | { |
| 635 | struct snd_card *card; |
| 636 | struct us122l *us122l; |
| 637 | struct list_head *p; |
| 638 | |
| 639 | card = usb_get_intfdata(intf); |
| 640 | if (!card) |
| 641 | return; |
| 642 | |
| 643 | snd_card_disconnect(card); |
| 644 | |
| 645 | us122l = US122L(card); |
| 646 | mutex_lock(&us122l->mutex); |
| 647 | us122l_stop(us122l); |
| 648 | mutex_unlock(&us122l->mutex); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 649 | |
| 650 | /* release the midi resources */ |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 651 | list_for_each(p, &us122l->midi_list) { |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 652 | snd_usbmidi_disconnect(p); |
| 653 | } |
| 654 | |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 655 | usb_put_intf(usb_ifnum_to_if(us122l->dev, 0)); |
| 656 | usb_put_intf(usb_ifnum_to_if(us122l->dev, 1)); |
| 657 | usb_put_dev(us122l->dev); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 658 | |
| 659 | while (atomic_read(&us122l->mmap_count)) |
| 660 | msleep(500); |
| 661 | |
| 662 | snd_card_free(card); |
| 663 | } |
| 664 | |
| 665 | static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message) |
| 666 | { |
| 667 | struct snd_card *card; |
| 668 | struct us122l *us122l; |
| 669 | struct list_head *p; |
| 670 | |
Julia Lawall | f4e9749 | 2009-01-01 18:14:35 +0100 | [diff] [blame] | 671 | card = usb_get_intfdata(intf); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 672 | if (!card) |
| 673 | return 0; |
| 674 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
| 675 | |
| 676 | us122l = US122L(card); |
| 677 | if (!us122l) |
| 678 | return 0; |
| 679 | |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 680 | list_for_each(p, &us122l->midi_list) |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 681 | snd_usbmidi_input_stop(p); |
| 682 | |
| 683 | mutex_lock(&us122l->mutex); |
| 684 | usb_stream_stop(&us122l->sk); |
| 685 | mutex_unlock(&us122l->mutex); |
| 686 | |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 690 | static int snd_us122l_resume(struct usb_interface *intf) |
| 691 | { |
| 692 | struct snd_card *card; |
| 693 | struct us122l *us122l; |
| 694 | struct list_head *p; |
| 695 | int err; |
| 696 | |
Julia Lawall | f4e9749 | 2009-01-01 18:14:35 +0100 | [diff] [blame] | 697 | card = usb_get_intfdata(intf); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 698 | if (!card) |
| 699 | return 0; |
| 700 | |
| 701 | us122l = US122L(card); |
| 702 | if (!us122l) |
| 703 | return 0; |
| 704 | |
| 705 | mutex_lock(&us122l->mutex); |
| 706 | /* needed, doesn't restart without: */ |
Tobias Hansen | 2b6f6c0 | 2009-12-07 19:08:19 +0100 | [diff] [blame] | 707 | if (us122l->dev->descriptor.idProduct == USB_ID_US144 || |
| 708 | us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 709 | err = usb_set_interface(us122l->dev, 0, 1); |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 710 | if (err) { |
| 711 | snd_printk(KERN_ERR "usb_set_interface error \n"); |
| 712 | goto unlock; |
| 713 | } |
| 714 | } |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 715 | err = usb_set_interface(us122l->dev, 1, 1); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 716 | if (err) { |
| 717 | snd_printk(KERN_ERR "usb_set_interface error \n"); |
| 718 | goto unlock; |
| 719 | } |
| 720 | |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 721 | pt_info_set(us122l->dev, 0x11); |
| 722 | pt_info_set(us122l->dev, 0x10); |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 723 | |
Clemens Ladisch | a014bba | 2009-11-16 12:26:30 +0100 | [diff] [blame] | 724 | err = us122l_set_sample_rate(us122l->dev, |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 725 | us122l->sk.s->cfg.sample_rate); |
| 726 | if (err < 0) { |
| 727 | snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); |
| 728 | goto unlock; |
| 729 | } |
| 730 | err = usb_stream_start(&us122l->sk); |
| 731 | if (err) |
| 732 | goto unlock; |
| 733 | |
Clemens Ladisch | d82af9f | 2009-11-16 12:23:46 +0100 | [diff] [blame] | 734 | list_for_each(p, &us122l->midi_list) |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 735 | snd_usbmidi_input_start(p); |
| 736 | unlock: |
| 737 | mutex_unlock(&us122l->mutex); |
| 738 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
| 739 | return err; |
| 740 | } |
| 741 | |
| 742 | static struct usb_device_id snd_us122l_usb_id_table[] = { |
| 743 | { |
| 744 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
| 745 | .idVendor = 0x0644, |
| 746 | .idProduct = USB_ID_US122L |
| 747 | }, |
Tobias Hansen | 4f27234 | 2009-09-22 16:52:08 +0200 | [diff] [blame] | 748 | { /* US-144 only works at USB1.1! Disable module ehci-hcd. */ |
| 749 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
| 750 | .idVendor = 0x0644, |
| 751 | .idProduct = USB_ID_US144 |
| 752 | }, |
Tobias Hansen | 2b6f6c0 | 2009-12-07 19:08:19 +0100 | [diff] [blame] | 753 | { |
| 754 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
| 755 | .idVendor = 0x0644, |
| 756 | .idProduct = USB_ID_US122MKII |
| 757 | }, |
| 758 | { |
| 759 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE, |
| 760 | .idVendor = 0x0644, |
| 761 | .idProduct = USB_ID_US144MKII |
| 762 | }, |
Karsten Wiese | 030a07e | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 763 | { /* terminator */ } |
| 764 | }; |
| 765 | |
| 766 | MODULE_DEVICE_TABLE(usb, snd_us122l_usb_id_table); |
| 767 | static struct usb_driver snd_us122l_usb_driver = { |
| 768 | .name = "snd-usb-us122l", |
| 769 | .probe = snd_us122l_probe, |
| 770 | .disconnect = snd_us122l_disconnect, |
| 771 | .suspend = snd_us122l_suspend, |
| 772 | .resume = snd_us122l_resume, |
| 773 | .reset_resume = snd_us122l_resume, |
| 774 | .id_table = snd_us122l_usb_id_table, |
| 775 | .supports_autosuspend = 1 |
| 776 | }; |
| 777 | |
Greg Kroah-Hartman | 424f075 | 2011-11-18 09:50:44 -0800 | [diff] [blame] | 778 | module_usb_driver(snd_us122l_usb_driver); |