1030a07e4SKarsten Wiese /* 2030a07e4SKarsten Wiese * Copyright (C) 2007, 2008 Karsten Wiese <fzu@wemgehoertderstaat.de> 3030a07e4SKarsten Wiese * 4030a07e4SKarsten Wiese * This program is free software; you can redistribute it and/or modify it 5030a07e4SKarsten Wiese * under the terms of the GNU General Public License as published by the 6030a07e4SKarsten Wiese * Free Software Foundation; either version 2 of the License, or (at your 7030a07e4SKarsten Wiese * option) any later version. 8030a07e4SKarsten Wiese * 9030a07e4SKarsten Wiese * This program is distributed in the hope that it will be useful, but 10030a07e4SKarsten Wiese * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11030a07e4SKarsten Wiese * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12030a07e4SKarsten Wiese * for more details. 13030a07e4SKarsten Wiese * 14030a07e4SKarsten Wiese * You should have received a copy of the GNU General Public License 15030a07e4SKarsten Wiese * along with this program; if not, write to the Free Software Foundation, 16030a07e4SKarsten Wiese * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17030a07e4SKarsten Wiese */ 18030a07e4SKarsten Wiese 195a0e3ad6STejun Heo #include <linux/slab.h> 20de48c7bcSDaniel Mack #include <linux/usb.h> 21de48c7bcSDaniel Mack #include <linux/usb/audio.h> 22030a07e4SKarsten Wiese #include <sound/core.h> 23030a07e4SKarsten Wiese #include <sound/hwdep.h> 24030a07e4SKarsten Wiese #include <sound/pcm.h> 25030a07e4SKarsten Wiese #include <sound/initval.h> 26030a07e4SKarsten Wiese #define MODNAME "US122L" 27030a07e4SKarsten Wiese #include "usb_stream.c" 28030a07e4SKarsten Wiese #include "../usbaudio.h" 29030a07e4SKarsten Wiese #include "us122l.h" 30030a07e4SKarsten Wiese 31030a07e4SKarsten Wiese MODULE_AUTHOR("Karsten Wiese <fzu@wemgehoertderstaat.de>"); 32030a07e4SKarsten Wiese MODULE_DESCRIPTION("TASCAM "NAME_ALLCAPS" Version 0.5"); 33030a07e4SKarsten Wiese MODULE_LICENSE("GPL"); 34030a07e4SKarsten Wiese 35030a07e4SKarsten Wiese static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ 36030a07e4SKarsten Wiese static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ 37030a07e4SKarsten Wiese /* Enable this card */ 38030a07e4SKarsten Wiese static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 39030a07e4SKarsten Wiese 40030a07e4SKarsten Wiese module_param_array(index, int, NULL, 0444); 41030a07e4SKarsten Wiese MODULE_PARM_DESC(index, "Index value for "NAME_ALLCAPS"."); 42030a07e4SKarsten Wiese module_param_array(id, charp, NULL, 0444); 43030a07e4SKarsten Wiese MODULE_PARM_DESC(id, "ID string for "NAME_ALLCAPS"."); 44030a07e4SKarsten Wiese module_param_array(enable, bool, NULL, 0444); 45030a07e4SKarsten Wiese MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS"."); 46030a07e4SKarsten Wiese 47030a07e4SKarsten Wiese static int snd_us122l_card_used[SNDRV_CARDS]; 48030a07e4SKarsten Wiese 49030a07e4SKarsten Wiese 50030a07e4SKarsten Wiese static int us122l_create_usbmidi(struct snd_card *card) 51030a07e4SKarsten Wiese { 52030a07e4SKarsten Wiese static struct snd_usb_midi_endpoint_info quirk_data = { 53030a07e4SKarsten Wiese .out_ep = 4, 54030a07e4SKarsten Wiese .in_ep = 3, 55030a07e4SKarsten Wiese .out_cables = 0x001, 56030a07e4SKarsten Wiese .in_cables = 0x001 57030a07e4SKarsten Wiese }; 58030a07e4SKarsten Wiese static struct snd_usb_audio_quirk quirk = { 59030a07e4SKarsten Wiese .vendor_name = "US122L", 60030a07e4SKarsten Wiese .product_name = NAME_ALLCAPS, 61030a07e4SKarsten Wiese .ifnum = 1, 62030a07e4SKarsten Wiese .type = QUIRK_MIDI_US122L, 63030a07e4SKarsten Wiese .data = &quirk_data 64030a07e4SKarsten Wiese }; 65a014bbadSClemens Ladisch struct usb_device *dev = US122L(card)->dev; 66030a07e4SKarsten Wiese struct usb_interface *iface = usb_ifnum_to_if(dev, 1); 67030a07e4SKarsten Wiese 68d82af9f9SClemens Ladisch return snd_usbmidi_create(card, iface, 69d82af9f9SClemens Ladisch &US122L(card)->midi_list, &quirk); 70030a07e4SKarsten Wiese } 71030a07e4SKarsten Wiese 724f272341STobias Hansen static int us144_create_usbmidi(struct snd_card *card) 734f272341STobias Hansen { 744f272341STobias Hansen static struct snd_usb_midi_endpoint_info quirk_data = { 754f272341STobias Hansen .out_ep = 4, 764f272341STobias Hansen .in_ep = 3, 774f272341STobias Hansen .out_cables = 0x001, 784f272341STobias Hansen .in_cables = 0x001 794f272341STobias Hansen }; 804f272341STobias Hansen static struct snd_usb_audio_quirk quirk = { 814f272341STobias Hansen .vendor_name = "US144", 824f272341STobias Hansen .product_name = NAME_ALLCAPS, 834f272341STobias Hansen .ifnum = 0, 844f272341STobias Hansen .type = QUIRK_MIDI_US122L, 854f272341STobias Hansen .data = &quirk_data 864f272341STobias Hansen }; 87a014bbadSClemens Ladisch struct usb_device *dev = US122L(card)->dev; 884f272341STobias Hansen struct usb_interface *iface = usb_ifnum_to_if(dev, 0); 894f272341STobias Hansen 90d82af9f9SClemens Ladisch return snd_usbmidi_create(card, iface, 91d82af9f9SClemens Ladisch &US122L(card)->midi_list, &quirk); 924f272341STobias Hansen } 934f272341STobias Hansen 94030a07e4SKarsten Wiese /* 95030a07e4SKarsten Wiese * Wrapper for usb_control_msg(). 96030a07e4SKarsten Wiese * Allocates a temp buffer to prevent dmaing from/to the stack. 97030a07e4SKarsten Wiese */ 98030a07e4SKarsten Wiese static int us122l_ctl_msg(struct usb_device *dev, unsigned int pipe, 99030a07e4SKarsten Wiese __u8 request, __u8 requesttype, 100030a07e4SKarsten Wiese __u16 value, __u16 index, void *data, 101030a07e4SKarsten Wiese __u16 size, int timeout) 102030a07e4SKarsten Wiese { 103030a07e4SKarsten Wiese int err; 104030a07e4SKarsten Wiese void *buf = NULL; 105030a07e4SKarsten Wiese 106030a07e4SKarsten Wiese if (size > 0) { 107030a07e4SKarsten Wiese buf = kmemdup(data, size, GFP_KERNEL); 108030a07e4SKarsten Wiese if (!buf) 109030a07e4SKarsten Wiese return -ENOMEM; 110030a07e4SKarsten Wiese } 111030a07e4SKarsten Wiese err = usb_control_msg(dev, pipe, request, requesttype, 112030a07e4SKarsten Wiese value, index, buf, size, timeout); 113030a07e4SKarsten Wiese if (size > 0) { 114030a07e4SKarsten Wiese memcpy(data, buf, size); 115030a07e4SKarsten Wiese kfree(buf); 116030a07e4SKarsten Wiese } 117030a07e4SKarsten Wiese return err; 118030a07e4SKarsten Wiese } 119030a07e4SKarsten Wiese 120030a07e4SKarsten Wiese static void pt_info_set(struct usb_device *dev, u8 v) 121030a07e4SKarsten Wiese { 122030a07e4SKarsten Wiese int ret; 123030a07e4SKarsten Wiese 124030a07e4SKarsten Wiese ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 125030a07e4SKarsten Wiese 'I', 126030a07e4SKarsten Wiese USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 127030a07e4SKarsten Wiese v, 0, NULL, 0, 1000); 128030a07e4SKarsten Wiese snd_printdd(KERN_DEBUG "%i\n", ret); 129030a07e4SKarsten Wiese } 130030a07e4SKarsten Wiese 131030a07e4SKarsten Wiese static void usb_stream_hwdep_vm_open(struct vm_area_struct *area) 132030a07e4SKarsten Wiese { 133030a07e4SKarsten Wiese struct us122l *us122l = area->vm_private_data; 134030a07e4SKarsten Wiese atomic_inc(&us122l->mmap_count); 135030a07e4SKarsten Wiese snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count)); 136030a07e4SKarsten Wiese } 137030a07e4SKarsten Wiese 138030a07e4SKarsten Wiese static int usb_stream_hwdep_vm_fault(struct vm_area_struct *area, 139030a07e4SKarsten Wiese struct vm_fault *vmf) 140030a07e4SKarsten Wiese { 141030a07e4SKarsten Wiese unsigned long offset; 142030a07e4SKarsten Wiese struct page *page; 143030a07e4SKarsten Wiese void *vaddr; 144030a07e4SKarsten Wiese struct us122l *us122l = area->vm_private_data; 145030a07e4SKarsten Wiese struct usb_stream *s; 146030a07e4SKarsten Wiese 147030a07e4SKarsten Wiese mutex_lock(&us122l->mutex); 148030a07e4SKarsten Wiese s = us122l->sk.s; 149030a07e4SKarsten Wiese if (!s) 150428ffb71SLi Zefan goto unlock; 151030a07e4SKarsten Wiese 152030a07e4SKarsten Wiese offset = vmf->pgoff << PAGE_SHIFT; 153030a07e4SKarsten Wiese if (offset < PAGE_ALIGN(s->read_size)) 154030a07e4SKarsten Wiese vaddr = (char *)s + offset; 155030a07e4SKarsten Wiese else { 156030a07e4SKarsten Wiese offset -= PAGE_ALIGN(s->read_size); 157030a07e4SKarsten Wiese if (offset >= PAGE_ALIGN(s->write_size)) 158428ffb71SLi Zefan goto unlock; 159030a07e4SKarsten Wiese 160030a07e4SKarsten Wiese vaddr = us122l->sk.write_page + offset; 161030a07e4SKarsten Wiese } 162030a07e4SKarsten Wiese page = virt_to_page(vaddr); 163030a07e4SKarsten Wiese 164030a07e4SKarsten Wiese get_page(page); 165030a07e4SKarsten Wiese mutex_unlock(&us122l->mutex); 166030a07e4SKarsten Wiese 167030a07e4SKarsten Wiese vmf->page = page; 168428ffb71SLi Zefan 169428ffb71SLi Zefan return 0; 170428ffb71SLi Zefan unlock: 171428ffb71SLi Zefan mutex_unlock(&us122l->mutex); 172428ffb71SLi Zefan return VM_FAULT_SIGBUS; 173030a07e4SKarsten Wiese } 174030a07e4SKarsten Wiese 175030a07e4SKarsten Wiese static void usb_stream_hwdep_vm_close(struct vm_area_struct *area) 176030a07e4SKarsten Wiese { 177030a07e4SKarsten Wiese struct us122l *us122l = area->vm_private_data; 178030a07e4SKarsten Wiese atomic_dec(&us122l->mmap_count); 179030a07e4SKarsten Wiese snd_printdd(KERN_DEBUG "%i\n", atomic_read(&us122l->mmap_count)); 180030a07e4SKarsten Wiese } 181030a07e4SKarsten Wiese 182f0f37e2fSAlexey Dobriyan static const struct vm_operations_struct usb_stream_hwdep_vm_ops = { 183030a07e4SKarsten Wiese .open = usb_stream_hwdep_vm_open, 184030a07e4SKarsten Wiese .fault = usb_stream_hwdep_vm_fault, 185030a07e4SKarsten Wiese .close = usb_stream_hwdep_vm_close, 186030a07e4SKarsten Wiese }; 187030a07e4SKarsten Wiese 188030a07e4SKarsten Wiese 189030a07e4SKarsten Wiese static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file) 190030a07e4SKarsten Wiese { 191030a07e4SKarsten Wiese struct us122l *us122l = hw->private_data; 192030a07e4SKarsten Wiese struct usb_interface *iface; 193030a07e4SKarsten Wiese snd_printdd(KERN_DEBUG "%p %p\n", hw, file); 194030a07e4SKarsten Wiese if (hw->used >= 2) 195030a07e4SKarsten Wiese return -EBUSY; 196030a07e4SKarsten Wiese 197030a07e4SKarsten Wiese if (!us122l->first) 198030a07e4SKarsten Wiese us122l->first = file; 1994f272341STobias Hansen 2002b6f6c0dSTobias Hansen if (us122l->dev->descriptor.idProduct == USB_ID_US144 || 2012b6f6c0dSTobias Hansen us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { 202a014bbadSClemens Ladisch iface = usb_ifnum_to_if(us122l->dev, 0); 2034f272341STobias Hansen usb_autopm_get_interface(iface); 2044f272341STobias Hansen } 205a014bbadSClemens Ladisch iface = usb_ifnum_to_if(us122l->dev, 1); 206030a07e4SKarsten Wiese usb_autopm_get_interface(iface); 207030a07e4SKarsten Wiese return 0; 208030a07e4SKarsten Wiese } 209030a07e4SKarsten Wiese 210030a07e4SKarsten Wiese static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file) 211030a07e4SKarsten Wiese { 212030a07e4SKarsten Wiese struct us122l *us122l = hw->private_data; 2134f272341STobias Hansen struct usb_interface *iface; 214030a07e4SKarsten Wiese snd_printdd(KERN_DEBUG "%p %p\n", hw, file); 2154f272341STobias Hansen 2162b6f6c0dSTobias Hansen if (us122l->dev->descriptor.idProduct == USB_ID_US144 || 2172b6f6c0dSTobias Hansen us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { 218a014bbadSClemens Ladisch iface = usb_ifnum_to_if(us122l->dev, 0); 2194f272341STobias Hansen usb_autopm_put_interface(iface); 2204f272341STobias Hansen } 221a014bbadSClemens Ladisch iface = usb_ifnum_to_if(us122l->dev, 1); 222030a07e4SKarsten Wiese usb_autopm_put_interface(iface); 223030a07e4SKarsten Wiese if (us122l->first == file) 224030a07e4SKarsten Wiese us122l->first = NULL; 225030a07e4SKarsten Wiese mutex_lock(&us122l->mutex); 226030a07e4SKarsten Wiese if (us122l->master == file) 227030a07e4SKarsten Wiese us122l->master = us122l->slave; 228030a07e4SKarsten Wiese 229030a07e4SKarsten Wiese us122l->slave = NULL; 230030a07e4SKarsten Wiese mutex_unlock(&us122l->mutex); 231030a07e4SKarsten Wiese return 0; 232030a07e4SKarsten Wiese } 233030a07e4SKarsten Wiese 234030a07e4SKarsten Wiese static int usb_stream_hwdep_mmap(struct snd_hwdep *hw, 235030a07e4SKarsten Wiese struct file *filp, struct vm_area_struct *area) 236030a07e4SKarsten Wiese { 237030a07e4SKarsten Wiese unsigned long size = area->vm_end - area->vm_start; 238030a07e4SKarsten Wiese struct us122l *us122l = hw->private_data; 239030a07e4SKarsten Wiese unsigned long offset; 240030a07e4SKarsten Wiese struct usb_stream *s; 241030a07e4SKarsten Wiese int err = 0; 242030a07e4SKarsten Wiese bool read; 243030a07e4SKarsten Wiese 244030a07e4SKarsten Wiese offset = area->vm_pgoff << PAGE_SHIFT; 245030a07e4SKarsten Wiese mutex_lock(&us122l->mutex); 246030a07e4SKarsten Wiese s = us122l->sk.s; 247030a07e4SKarsten Wiese read = offset < s->read_size; 248030a07e4SKarsten Wiese if (read && area->vm_flags & VM_WRITE) { 249030a07e4SKarsten Wiese err = -EPERM; 250030a07e4SKarsten Wiese goto out; 251030a07e4SKarsten Wiese } 252030a07e4SKarsten Wiese snd_printdd(KERN_DEBUG "%lu %u\n", size, 253030a07e4SKarsten Wiese read ? s->read_size : s->write_size); 254030a07e4SKarsten Wiese /* if userspace tries to mmap beyond end of our buffer, fail */ 255030a07e4SKarsten Wiese if (size > PAGE_ALIGN(read ? s->read_size : s->write_size)) { 256030a07e4SKarsten Wiese snd_printk(KERN_WARNING "%lu > %u\n", size, 257030a07e4SKarsten Wiese read ? s->read_size : s->write_size); 258030a07e4SKarsten Wiese err = -EINVAL; 259030a07e4SKarsten Wiese goto out; 260030a07e4SKarsten Wiese } 261030a07e4SKarsten Wiese 262030a07e4SKarsten Wiese area->vm_ops = &usb_stream_hwdep_vm_ops; 263030a07e4SKarsten Wiese area->vm_flags |= VM_RESERVED; 264030a07e4SKarsten Wiese area->vm_private_data = us122l; 265030a07e4SKarsten Wiese atomic_inc(&us122l->mmap_count); 266030a07e4SKarsten Wiese out: 267030a07e4SKarsten Wiese mutex_unlock(&us122l->mutex); 268030a07e4SKarsten Wiese return err; 269030a07e4SKarsten Wiese } 270030a07e4SKarsten Wiese 271030a07e4SKarsten Wiese static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw, 272030a07e4SKarsten Wiese struct file *file, poll_table *wait) 273030a07e4SKarsten Wiese { 274030a07e4SKarsten Wiese struct us122l *us122l = hw->private_data; 275030a07e4SKarsten Wiese struct usb_stream *s = us122l->sk.s; 276030a07e4SKarsten Wiese unsigned *polled; 277030a07e4SKarsten Wiese unsigned int mask; 278030a07e4SKarsten Wiese 279030a07e4SKarsten Wiese poll_wait(file, &us122l->sk.sleep, wait); 280030a07e4SKarsten Wiese 281030a07e4SKarsten Wiese switch (s->state) { 282030a07e4SKarsten Wiese case usb_stream_ready: 283030a07e4SKarsten Wiese if (us122l->first == file) 284030a07e4SKarsten Wiese polled = &s->periods_polled; 285030a07e4SKarsten Wiese else 286030a07e4SKarsten Wiese polled = &us122l->second_periods_polled; 287030a07e4SKarsten Wiese if (*polled != s->periods_done) { 288030a07e4SKarsten Wiese *polled = s->periods_done; 289030a07e4SKarsten Wiese mask = POLLIN | POLLOUT | POLLWRNORM; 290030a07e4SKarsten Wiese break; 291030a07e4SKarsten Wiese } 292030a07e4SKarsten Wiese /* Fall through */ 293030a07e4SKarsten Wiese mask = 0; 294030a07e4SKarsten Wiese break; 295030a07e4SKarsten Wiese default: 296030a07e4SKarsten Wiese mask = POLLIN | POLLOUT | POLLWRNORM | POLLERR; 297030a07e4SKarsten Wiese break; 298030a07e4SKarsten Wiese } 299030a07e4SKarsten Wiese return mask; 300030a07e4SKarsten Wiese } 301030a07e4SKarsten Wiese 302030a07e4SKarsten Wiese static void us122l_stop(struct us122l *us122l) 303030a07e4SKarsten Wiese { 304030a07e4SKarsten Wiese struct list_head *p; 305d82af9f9SClemens Ladisch list_for_each(p, &us122l->midi_list) 306030a07e4SKarsten Wiese snd_usbmidi_input_stop(p); 307030a07e4SKarsten Wiese 308030a07e4SKarsten Wiese usb_stream_stop(&us122l->sk); 309030a07e4SKarsten Wiese usb_stream_free(&us122l->sk); 310030a07e4SKarsten Wiese } 311030a07e4SKarsten Wiese 312030a07e4SKarsten Wiese static int us122l_set_sample_rate(struct usb_device *dev, int rate) 313030a07e4SKarsten Wiese { 314030a07e4SKarsten Wiese unsigned int ep = 0x81; 315030a07e4SKarsten Wiese unsigned char data[3]; 316030a07e4SKarsten Wiese int err; 317030a07e4SKarsten Wiese 318030a07e4SKarsten Wiese data[0] = rate; 319030a07e4SKarsten Wiese data[1] = rate >> 8; 320030a07e4SKarsten Wiese data[2] = rate >> 16; 321de48c7bcSDaniel Mack err = us122l_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, 322030a07e4SKarsten Wiese USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 323de48c7bcSDaniel Mack UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, 3, 1000); 324030a07e4SKarsten Wiese if (err < 0) 325030a07e4SKarsten Wiese snd_printk(KERN_ERR "%d: cannot set freq %d to ep 0x%x\n", 326030a07e4SKarsten Wiese dev->devnum, rate, ep); 327030a07e4SKarsten Wiese return err; 328030a07e4SKarsten Wiese } 329030a07e4SKarsten Wiese 330030a07e4SKarsten Wiese static bool us122l_start(struct us122l *us122l, 331030a07e4SKarsten Wiese unsigned rate, unsigned period_frames) 332030a07e4SKarsten Wiese { 333030a07e4SKarsten Wiese struct list_head *p; 334030a07e4SKarsten Wiese int err; 335030a07e4SKarsten Wiese unsigned use_packsize = 0; 336030a07e4SKarsten Wiese bool success = false; 337030a07e4SKarsten Wiese 338a014bbadSClemens Ladisch if (us122l->dev->speed == USB_SPEED_HIGH) { 339030a07e4SKarsten Wiese /* The us-122l's descriptor defaults to iso max_packsize 78, 340030a07e4SKarsten Wiese which isn't needed for samplerates <= 48000. 341030a07e4SKarsten Wiese Lets save some memory: 342030a07e4SKarsten Wiese */ 343030a07e4SKarsten Wiese switch (rate) { 344030a07e4SKarsten Wiese case 44100: 345030a07e4SKarsten Wiese use_packsize = 36; 346030a07e4SKarsten Wiese break; 347030a07e4SKarsten Wiese case 48000: 348030a07e4SKarsten Wiese use_packsize = 42; 349030a07e4SKarsten Wiese break; 350030a07e4SKarsten Wiese case 88200: 351030a07e4SKarsten Wiese use_packsize = 72; 352030a07e4SKarsten Wiese break; 353030a07e4SKarsten Wiese } 354030a07e4SKarsten Wiese } 355a014bbadSClemens Ladisch if (!usb_stream_new(&us122l->sk, us122l->dev, 1, 2, 356030a07e4SKarsten Wiese rate, use_packsize, period_frames, 6)) 357030a07e4SKarsten Wiese goto out; 358030a07e4SKarsten Wiese 359a014bbadSClemens Ladisch err = us122l_set_sample_rate(us122l->dev, rate); 360030a07e4SKarsten Wiese if (err < 0) { 361030a07e4SKarsten Wiese us122l_stop(us122l); 362030a07e4SKarsten Wiese snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); 363030a07e4SKarsten Wiese goto out; 364030a07e4SKarsten Wiese } 365030a07e4SKarsten Wiese err = usb_stream_start(&us122l->sk); 366030a07e4SKarsten Wiese if (err < 0) { 367030a07e4SKarsten Wiese us122l_stop(us122l); 368030a07e4SKarsten Wiese snd_printk(KERN_ERR "us122l_start error %i \n", err); 369030a07e4SKarsten Wiese goto out; 370030a07e4SKarsten Wiese } 371d82af9f9SClemens Ladisch list_for_each(p, &us122l->midi_list) 372030a07e4SKarsten Wiese snd_usbmidi_input_start(p); 373030a07e4SKarsten Wiese success = true; 374030a07e4SKarsten Wiese out: 375030a07e4SKarsten Wiese return success; 376030a07e4SKarsten Wiese } 377030a07e4SKarsten Wiese 378030a07e4SKarsten Wiese static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, 379030a07e4SKarsten Wiese unsigned cmd, unsigned long arg) 380030a07e4SKarsten Wiese { 381030a07e4SKarsten Wiese struct usb_stream_config *cfg; 382030a07e4SKarsten Wiese struct us122l *us122l = hw->private_data; 383030a07e4SKarsten Wiese unsigned min_period_frames; 384030a07e4SKarsten Wiese int err = 0; 385030a07e4SKarsten Wiese bool high_speed; 386030a07e4SKarsten Wiese 387030a07e4SKarsten Wiese if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) 388030a07e4SKarsten Wiese return -ENOTTY; 389030a07e4SKarsten Wiese 39085385c15SLi Zefan cfg = memdup_user((void *)arg, sizeof(*cfg)); 39185385c15SLi Zefan if (IS_ERR(cfg)) 39285385c15SLi Zefan return PTR_ERR(cfg); 393030a07e4SKarsten Wiese 394030a07e4SKarsten Wiese if (cfg->version != USB_STREAM_INTERFACE_VERSION) { 395030a07e4SKarsten Wiese err = -ENXIO; 396030a07e4SKarsten Wiese goto free; 397030a07e4SKarsten Wiese } 398a014bbadSClemens Ladisch high_speed = us122l->dev->speed == USB_SPEED_HIGH; 399030a07e4SKarsten Wiese if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 && 400030a07e4SKarsten Wiese (!high_speed || 401030a07e4SKarsten Wiese (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) || 402030a07e4SKarsten Wiese cfg->frame_size != 6 || 403030a07e4SKarsten Wiese cfg->period_frames > 0x3000) { 404030a07e4SKarsten Wiese err = -EINVAL; 405030a07e4SKarsten Wiese goto free; 406030a07e4SKarsten Wiese } 407030a07e4SKarsten Wiese switch (cfg->sample_rate) { 408030a07e4SKarsten Wiese case 44100: 409030a07e4SKarsten Wiese min_period_frames = 48; 410030a07e4SKarsten Wiese break; 411030a07e4SKarsten Wiese case 48000: 412030a07e4SKarsten Wiese min_period_frames = 52; 413030a07e4SKarsten Wiese break; 414030a07e4SKarsten Wiese default: 415030a07e4SKarsten Wiese min_period_frames = 104; 416030a07e4SKarsten Wiese break; 417030a07e4SKarsten Wiese } 418030a07e4SKarsten Wiese if (!high_speed) 419030a07e4SKarsten Wiese min_period_frames <<= 1; 420030a07e4SKarsten Wiese if (cfg->period_frames < min_period_frames) { 421030a07e4SKarsten Wiese err = -EINVAL; 422030a07e4SKarsten Wiese goto free; 423030a07e4SKarsten Wiese } 424030a07e4SKarsten Wiese 425030a07e4SKarsten Wiese snd_power_wait(hw->card, SNDRV_CTL_POWER_D0); 426030a07e4SKarsten Wiese 427030a07e4SKarsten Wiese mutex_lock(&us122l->mutex); 428030a07e4SKarsten Wiese if (!us122l->master) 429030a07e4SKarsten Wiese us122l->master = file; 430030a07e4SKarsten Wiese else if (us122l->master != file) { 431030a07e4SKarsten Wiese if (memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg))) { 432030a07e4SKarsten Wiese err = -EIO; 433030a07e4SKarsten Wiese goto unlock; 434030a07e4SKarsten Wiese } 435030a07e4SKarsten Wiese us122l->slave = file; 436030a07e4SKarsten Wiese } 437030a07e4SKarsten Wiese if (!us122l->sk.s || 438030a07e4SKarsten Wiese memcmp(cfg, &us122l->sk.s->cfg, sizeof(*cfg)) || 439030a07e4SKarsten Wiese us122l->sk.s->state == usb_stream_xrun) { 440030a07e4SKarsten Wiese us122l_stop(us122l); 441030a07e4SKarsten Wiese if (!us122l_start(us122l, cfg->sample_rate, cfg->period_frames)) 442030a07e4SKarsten Wiese err = -EIO; 443030a07e4SKarsten Wiese else 444030a07e4SKarsten Wiese err = 1; 445030a07e4SKarsten Wiese } 446030a07e4SKarsten Wiese unlock: 447030a07e4SKarsten Wiese mutex_unlock(&us122l->mutex); 448030a07e4SKarsten Wiese free: 449030a07e4SKarsten Wiese kfree(cfg); 450030a07e4SKarsten Wiese return err; 451030a07e4SKarsten Wiese } 452030a07e4SKarsten Wiese 453030a07e4SKarsten Wiese #define SND_USB_STREAM_ID "USB STREAM" 454030a07e4SKarsten Wiese static int usb_stream_hwdep_new(struct snd_card *card) 455030a07e4SKarsten Wiese { 456030a07e4SKarsten Wiese int err; 457030a07e4SKarsten Wiese struct snd_hwdep *hw; 458a014bbadSClemens Ladisch struct usb_device *dev = US122L(card)->dev; 459030a07e4SKarsten Wiese 460030a07e4SKarsten Wiese err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw); 461030a07e4SKarsten Wiese if (err < 0) 462030a07e4SKarsten Wiese return err; 463030a07e4SKarsten Wiese 464030a07e4SKarsten Wiese hw->iface = SNDRV_HWDEP_IFACE_USB_STREAM; 465030a07e4SKarsten Wiese hw->private_data = US122L(card); 466030a07e4SKarsten Wiese hw->ops.open = usb_stream_hwdep_open; 467030a07e4SKarsten Wiese hw->ops.release = usb_stream_hwdep_release; 468030a07e4SKarsten Wiese hw->ops.ioctl = usb_stream_hwdep_ioctl; 469030a07e4SKarsten Wiese hw->ops.ioctl_compat = usb_stream_hwdep_ioctl; 470030a07e4SKarsten Wiese hw->ops.mmap = usb_stream_hwdep_mmap; 471030a07e4SKarsten Wiese hw->ops.poll = usb_stream_hwdep_poll; 472030a07e4SKarsten Wiese 473030a07e4SKarsten Wiese sprintf(hw->name, "/proc/bus/usb/%03d/%03d/hwdeppcm", 474030a07e4SKarsten Wiese dev->bus->busnum, dev->devnum); 475030a07e4SKarsten Wiese return 0; 476030a07e4SKarsten Wiese } 477030a07e4SKarsten Wiese 478030a07e4SKarsten Wiese 479030a07e4SKarsten Wiese static bool us122l_create_card(struct snd_card *card) 480030a07e4SKarsten Wiese { 481030a07e4SKarsten Wiese int err; 482030a07e4SKarsten Wiese struct us122l *us122l = US122L(card); 483030a07e4SKarsten Wiese 4842b6f6c0dSTobias Hansen if (us122l->dev->descriptor.idProduct == USB_ID_US144 || 4852b6f6c0dSTobias Hansen us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { 486a014bbadSClemens Ladisch err = usb_set_interface(us122l->dev, 0, 1); 4874f272341STobias Hansen if (err) { 4884f272341STobias Hansen snd_printk(KERN_ERR "usb_set_interface error \n"); 4894f272341STobias Hansen return false; 4904f272341STobias Hansen } 4914f272341STobias Hansen } 492a014bbadSClemens Ladisch err = usb_set_interface(us122l->dev, 1, 1); 493030a07e4SKarsten Wiese if (err) { 494030a07e4SKarsten Wiese snd_printk(KERN_ERR "usb_set_interface error \n"); 495030a07e4SKarsten Wiese return false; 496030a07e4SKarsten Wiese } 497030a07e4SKarsten Wiese 498a014bbadSClemens Ladisch pt_info_set(us122l->dev, 0x11); 499a014bbadSClemens Ladisch pt_info_set(us122l->dev, 0x10); 500030a07e4SKarsten Wiese 501030a07e4SKarsten Wiese if (!us122l_start(us122l, 44100, 256)) 502030a07e4SKarsten Wiese return false; 503030a07e4SKarsten Wiese 5042b6f6c0dSTobias Hansen if (us122l->dev->descriptor.idProduct == USB_ID_US144 || 5052b6f6c0dSTobias Hansen us122l->dev->descriptor.idProduct == USB_ID_US144MKII) 5064f272341STobias Hansen err = us144_create_usbmidi(card); 5074f272341STobias Hansen else 508030a07e4SKarsten Wiese err = us122l_create_usbmidi(card); 509030a07e4SKarsten Wiese if (err < 0) { 510030a07e4SKarsten Wiese snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err); 511030a07e4SKarsten Wiese us122l_stop(us122l); 512030a07e4SKarsten Wiese return false; 513030a07e4SKarsten Wiese } 514030a07e4SKarsten Wiese err = usb_stream_hwdep_new(card); 515030a07e4SKarsten Wiese if (err < 0) { 516030a07e4SKarsten Wiese /* release the midi resources */ 517030a07e4SKarsten Wiese struct list_head *p; 518d82af9f9SClemens Ladisch list_for_each(p, &us122l->midi_list) 519030a07e4SKarsten Wiese snd_usbmidi_disconnect(p); 520030a07e4SKarsten Wiese 521030a07e4SKarsten Wiese us122l_stop(us122l); 522030a07e4SKarsten Wiese return false; 523030a07e4SKarsten Wiese } 524030a07e4SKarsten Wiese return true; 525030a07e4SKarsten Wiese } 526030a07e4SKarsten Wiese 5275d4af1beSKarsten Wiese static void snd_us122l_free(struct snd_card *card) 5285d4af1beSKarsten Wiese { 5295d4af1beSKarsten Wiese struct us122l *us122l = US122L(card); 530a014bbadSClemens Ladisch int index = us122l->card_index; 5315d4af1beSKarsten Wiese if (index >= 0 && index < SNDRV_CARDS) 5325d4af1beSKarsten Wiese snd_us122l_card_used[index] = 0; 5335d4af1beSKarsten Wiese } 5345d4af1beSKarsten Wiese 53551721f70STakashi Iwai static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) 536030a07e4SKarsten Wiese { 537030a07e4SKarsten Wiese int dev; 538030a07e4SKarsten Wiese struct snd_card *card; 539bd7dd77cSTakashi Iwai int err; 540bd7dd77cSTakashi Iwai 541030a07e4SKarsten Wiese for (dev = 0; dev < SNDRV_CARDS; ++dev) 542030a07e4SKarsten Wiese if (enable[dev] && !snd_us122l_card_used[dev]) 543030a07e4SKarsten Wiese break; 544030a07e4SKarsten Wiese if (dev >= SNDRV_CARDS) 54551721f70STakashi Iwai return -ENODEV; 546bd7dd77cSTakashi Iwai err = snd_card_create(index[dev], id[dev], THIS_MODULE, 547bd7dd77cSTakashi Iwai sizeof(struct us122l), &card); 548bd7dd77cSTakashi Iwai if (err < 0) 54951721f70STakashi Iwai return err; 550a014bbadSClemens Ladisch snd_us122l_card_used[US122L(card)->card_index = dev] = 1; 5515d4af1beSKarsten Wiese card->private_free = snd_us122l_free; 552a014bbadSClemens Ladisch US122L(card)->dev = device; 553030a07e4SKarsten Wiese mutex_init(&US122L(card)->mutex); 554030a07e4SKarsten Wiese init_waitqueue_head(&US122L(card)->sk.sleep); 555d82af9f9SClemens Ladisch INIT_LIST_HEAD(&US122L(card)->midi_list); 556030a07e4SKarsten Wiese strcpy(card->driver, "USB "NAME_ALLCAPS""); 557030a07e4SKarsten Wiese sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); 558030a07e4SKarsten Wiese sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", 559030a07e4SKarsten Wiese card->shortname, 560030a07e4SKarsten Wiese le16_to_cpu(device->descriptor.idVendor), 561030a07e4SKarsten Wiese le16_to_cpu(device->descriptor.idProduct), 562030a07e4SKarsten Wiese 0, 563a014bbadSClemens Ladisch US122L(card)->dev->bus->busnum, 564a014bbadSClemens Ladisch US122L(card)->dev->devnum 565030a07e4SKarsten Wiese ); 56651721f70STakashi Iwai *cardp = card; 56751721f70STakashi Iwai return 0; 568030a07e4SKarsten Wiese } 569030a07e4SKarsten Wiese 57051721f70STakashi Iwai static int us122l_usb_probe(struct usb_interface *intf, 57151721f70STakashi Iwai const struct usb_device_id *device_id, 57251721f70STakashi Iwai struct snd_card **cardp) 573030a07e4SKarsten Wiese { 574030a07e4SKarsten Wiese struct usb_device *device = interface_to_usbdev(intf); 57551721f70STakashi Iwai struct snd_card *card; 57651721f70STakashi Iwai int err; 577030a07e4SKarsten Wiese 57851721f70STakashi Iwai err = usx2y_create_card(device, &card); 57951721f70STakashi Iwai if (err < 0) 58051721f70STakashi Iwai return err; 581030a07e4SKarsten Wiese 5823f5d3465STakashi Iwai snd_card_set_dev(card, &intf->dev); 58351721f70STakashi Iwai if (!us122l_create_card(card)) { 584030a07e4SKarsten Wiese snd_card_free(card); 58551721f70STakashi Iwai return -EINVAL; 58651721f70STakashi Iwai } 58751721f70STakashi Iwai 58851721f70STakashi Iwai err = snd_card_register(card); 58951721f70STakashi Iwai if (err < 0) { 59051721f70STakashi Iwai snd_card_free(card); 59151721f70STakashi Iwai return err; 592030a07e4SKarsten Wiese } 593030a07e4SKarsten Wiese 5944f272341STobias Hansen usb_get_intf(usb_ifnum_to_if(device, 0)); 595030a07e4SKarsten Wiese usb_get_dev(device); 59651721f70STakashi Iwai *cardp = card; 59751721f70STakashi Iwai return 0; 598030a07e4SKarsten Wiese } 599030a07e4SKarsten Wiese 600030a07e4SKarsten Wiese static int snd_us122l_probe(struct usb_interface *intf, 601030a07e4SKarsten Wiese const struct usb_device_id *id) 602030a07e4SKarsten Wiese { 6034f272341STobias Hansen struct usb_device *device = interface_to_usbdev(intf); 604030a07e4SKarsten Wiese struct snd_card *card; 60551721f70STakashi Iwai int err; 60651721f70STakashi Iwai 6072b6f6c0dSTobias Hansen if ((device->descriptor.idProduct == USB_ID_US144 || 6082b6f6c0dSTobias Hansen device->descriptor.idProduct == USB_ID_US144MKII) 6094f272341STobias Hansen && device->speed == USB_SPEED_HIGH) { 6104f272341STobias Hansen snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n"); 611a688e488STobias Hansen return -ENODEV; 6124f272341STobias Hansen } 6134f272341STobias Hansen 614030a07e4SKarsten Wiese snd_printdd(KERN_DEBUG"%p:%i\n", 615030a07e4SKarsten Wiese intf, intf->cur_altsetting->desc.bInterfaceNumber); 616030a07e4SKarsten Wiese if (intf->cur_altsetting->desc.bInterfaceNumber != 1) 617030a07e4SKarsten Wiese return 0; 618030a07e4SKarsten Wiese 61951721f70STakashi Iwai err = us122l_usb_probe(usb_get_intf(intf), id, &card); 62051721f70STakashi Iwai if (err < 0) { 62151721f70STakashi Iwai usb_put_intf(intf); 62251721f70STakashi Iwai return err; 623030a07e4SKarsten Wiese } 624030a07e4SKarsten Wiese 62551721f70STakashi Iwai usb_set_intfdata(intf, card); 62651721f70STakashi Iwai return 0; 627030a07e4SKarsten Wiese } 628030a07e4SKarsten Wiese 629030a07e4SKarsten Wiese static void snd_us122l_disconnect(struct usb_interface *intf) 630030a07e4SKarsten Wiese { 631030a07e4SKarsten Wiese struct snd_card *card; 632030a07e4SKarsten Wiese struct us122l *us122l; 633030a07e4SKarsten Wiese struct list_head *p; 634030a07e4SKarsten Wiese 635030a07e4SKarsten Wiese card = usb_get_intfdata(intf); 636030a07e4SKarsten Wiese if (!card) 637030a07e4SKarsten Wiese return; 638030a07e4SKarsten Wiese 639030a07e4SKarsten Wiese snd_card_disconnect(card); 640030a07e4SKarsten Wiese 641030a07e4SKarsten Wiese us122l = US122L(card); 642030a07e4SKarsten Wiese mutex_lock(&us122l->mutex); 643030a07e4SKarsten Wiese us122l_stop(us122l); 644030a07e4SKarsten Wiese mutex_unlock(&us122l->mutex); 645030a07e4SKarsten Wiese 646030a07e4SKarsten Wiese /* release the midi resources */ 647d82af9f9SClemens Ladisch list_for_each(p, &us122l->midi_list) { 648030a07e4SKarsten Wiese snd_usbmidi_disconnect(p); 649030a07e4SKarsten Wiese } 650030a07e4SKarsten Wiese 651a014bbadSClemens Ladisch usb_put_intf(usb_ifnum_to_if(us122l->dev, 0)); 652a014bbadSClemens Ladisch usb_put_intf(usb_ifnum_to_if(us122l->dev, 1)); 653a014bbadSClemens Ladisch usb_put_dev(us122l->dev); 654030a07e4SKarsten Wiese 655030a07e4SKarsten Wiese while (atomic_read(&us122l->mmap_count)) 656030a07e4SKarsten Wiese msleep(500); 657030a07e4SKarsten Wiese 658030a07e4SKarsten Wiese snd_card_free(card); 659030a07e4SKarsten Wiese } 660030a07e4SKarsten Wiese 661030a07e4SKarsten Wiese static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message) 662030a07e4SKarsten Wiese { 663030a07e4SKarsten Wiese struct snd_card *card; 664030a07e4SKarsten Wiese struct us122l *us122l; 665030a07e4SKarsten Wiese struct list_head *p; 666030a07e4SKarsten Wiese 667f4e9749fSJulia Lawall card = usb_get_intfdata(intf); 668030a07e4SKarsten Wiese if (!card) 669030a07e4SKarsten Wiese return 0; 670030a07e4SKarsten Wiese snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 671030a07e4SKarsten Wiese 672030a07e4SKarsten Wiese us122l = US122L(card); 673030a07e4SKarsten Wiese if (!us122l) 674030a07e4SKarsten Wiese return 0; 675030a07e4SKarsten Wiese 676d82af9f9SClemens Ladisch list_for_each(p, &us122l->midi_list) 677030a07e4SKarsten Wiese snd_usbmidi_input_stop(p); 678030a07e4SKarsten Wiese 679030a07e4SKarsten Wiese mutex_lock(&us122l->mutex); 680030a07e4SKarsten Wiese usb_stream_stop(&us122l->sk); 681030a07e4SKarsten Wiese mutex_unlock(&us122l->mutex); 682030a07e4SKarsten Wiese 683030a07e4SKarsten Wiese return 0; 684030a07e4SKarsten Wiese } 685030a07e4SKarsten Wiese 686030a07e4SKarsten Wiese static int snd_us122l_resume(struct usb_interface *intf) 687030a07e4SKarsten Wiese { 688030a07e4SKarsten Wiese struct snd_card *card; 689030a07e4SKarsten Wiese struct us122l *us122l; 690030a07e4SKarsten Wiese struct list_head *p; 691030a07e4SKarsten Wiese int err; 692030a07e4SKarsten Wiese 693f4e9749fSJulia Lawall card = usb_get_intfdata(intf); 694030a07e4SKarsten Wiese if (!card) 695030a07e4SKarsten Wiese return 0; 696030a07e4SKarsten Wiese 697030a07e4SKarsten Wiese us122l = US122L(card); 698030a07e4SKarsten Wiese if (!us122l) 699030a07e4SKarsten Wiese return 0; 700030a07e4SKarsten Wiese 701030a07e4SKarsten Wiese mutex_lock(&us122l->mutex); 702030a07e4SKarsten Wiese /* needed, doesn't restart without: */ 7032b6f6c0dSTobias Hansen if (us122l->dev->descriptor.idProduct == USB_ID_US144 || 7042b6f6c0dSTobias Hansen us122l->dev->descriptor.idProduct == USB_ID_US144MKII) { 705a014bbadSClemens Ladisch err = usb_set_interface(us122l->dev, 0, 1); 7064f272341STobias Hansen if (err) { 7074f272341STobias Hansen snd_printk(KERN_ERR "usb_set_interface error \n"); 7084f272341STobias Hansen goto unlock; 7094f272341STobias Hansen } 7104f272341STobias Hansen } 711a014bbadSClemens Ladisch err = usb_set_interface(us122l->dev, 1, 1); 712030a07e4SKarsten Wiese if (err) { 713030a07e4SKarsten Wiese snd_printk(KERN_ERR "usb_set_interface error \n"); 714030a07e4SKarsten Wiese goto unlock; 715030a07e4SKarsten Wiese } 716030a07e4SKarsten Wiese 717a014bbadSClemens Ladisch pt_info_set(us122l->dev, 0x11); 718a014bbadSClemens Ladisch pt_info_set(us122l->dev, 0x10); 719030a07e4SKarsten Wiese 720a014bbadSClemens Ladisch err = us122l_set_sample_rate(us122l->dev, 721030a07e4SKarsten Wiese us122l->sk.s->cfg.sample_rate); 722030a07e4SKarsten Wiese if (err < 0) { 723030a07e4SKarsten Wiese snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); 724030a07e4SKarsten Wiese goto unlock; 725030a07e4SKarsten Wiese } 726030a07e4SKarsten Wiese err = usb_stream_start(&us122l->sk); 727030a07e4SKarsten Wiese if (err) 728030a07e4SKarsten Wiese goto unlock; 729030a07e4SKarsten Wiese 730d82af9f9SClemens Ladisch list_for_each(p, &us122l->midi_list) 731030a07e4SKarsten Wiese snd_usbmidi_input_start(p); 732030a07e4SKarsten Wiese unlock: 733030a07e4SKarsten Wiese mutex_unlock(&us122l->mutex); 734030a07e4SKarsten Wiese snd_power_change_state(card, SNDRV_CTL_POWER_D0); 735030a07e4SKarsten Wiese return err; 736030a07e4SKarsten Wiese } 737030a07e4SKarsten Wiese 738030a07e4SKarsten Wiese static struct usb_device_id snd_us122l_usb_id_table[] = { 739030a07e4SKarsten Wiese { 740030a07e4SKarsten Wiese .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 741030a07e4SKarsten Wiese .idVendor = 0x0644, 742030a07e4SKarsten Wiese .idProduct = USB_ID_US122L 743030a07e4SKarsten Wiese }, 7444f272341STobias Hansen { /* US-144 only works at USB1.1! Disable module ehci-hcd. */ 7454f272341STobias Hansen .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 7464f272341STobias Hansen .idVendor = 0x0644, 7474f272341STobias Hansen .idProduct = USB_ID_US144 7484f272341STobias Hansen }, 7492b6f6c0dSTobias Hansen { 7502b6f6c0dSTobias Hansen .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 7512b6f6c0dSTobias Hansen .idVendor = 0x0644, 7522b6f6c0dSTobias Hansen .idProduct = USB_ID_US122MKII 7532b6f6c0dSTobias Hansen }, 7542b6f6c0dSTobias Hansen { 7552b6f6c0dSTobias Hansen .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 7562b6f6c0dSTobias Hansen .idVendor = 0x0644, 7572b6f6c0dSTobias Hansen .idProduct = USB_ID_US144MKII 7582b6f6c0dSTobias Hansen }, 759030a07e4SKarsten Wiese { /* terminator */ } 760030a07e4SKarsten Wiese }; 761030a07e4SKarsten Wiese 762030a07e4SKarsten Wiese MODULE_DEVICE_TABLE(usb, snd_us122l_usb_id_table); 763030a07e4SKarsten Wiese static struct usb_driver snd_us122l_usb_driver = { 764030a07e4SKarsten Wiese .name = "snd-usb-us122l", 765030a07e4SKarsten Wiese .probe = snd_us122l_probe, 766030a07e4SKarsten Wiese .disconnect = snd_us122l_disconnect, 767030a07e4SKarsten Wiese .suspend = snd_us122l_suspend, 768030a07e4SKarsten Wiese .resume = snd_us122l_resume, 769030a07e4SKarsten Wiese .reset_resume = snd_us122l_resume, 770030a07e4SKarsten Wiese .id_table = snd_us122l_usb_id_table, 771030a07e4SKarsten Wiese .supports_autosuspend = 1 772030a07e4SKarsten Wiese }; 773030a07e4SKarsten Wiese 774030a07e4SKarsten Wiese 775030a07e4SKarsten Wiese static int __init snd_us122l_module_init(void) 776030a07e4SKarsten Wiese { 777030a07e4SKarsten Wiese return usb_register(&snd_us122l_usb_driver); 778030a07e4SKarsten Wiese } 779030a07e4SKarsten Wiese 780030a07e4SKarsten Wiese static void __exit snd_us122l_module_exit(void) 781030a07e4SKarsten Wiese { 782030a07e4SKarsten Wiese usb_deregister(&snd_us122l_usb_driver); 783030a07e4SKarsten Wiese } 784030a07e4SKarsten Wiese 785030a07e4SKarsten Wiese module_init(snd_us122l_module_init) 786030a07e4SKarsten Wiese module_exit(snd_us122l_module_exit) 787