blob: 3acfa79321ad641976b72797e3ec816c8bac7971 [file] [log] [blame]
Daniel Macke5779992010-03-04 19:46:13 +01001/*
2 * (Tentative) USB Audio Driver for ALSA
3 *
4 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
5 *
6 * Many codes borrowed from audio.c by
7 * Alan Cox (alan@lxorguk.ukuu.org.uk)
8 * Thomas Sailer (sailer@ife.ee.ethz.ch)
9 *
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 *
26 * NOTES:
27 *
Daniel Macke5779992010-03-04 19:46:13 +010028 * - the linked URBs would be preferred but not used so far because of
29 * the instability of unlinking.
30 * - type II is not supported properly. there is no device which supports
31 * this type *correctly*. SB extigy looks as if it supports, but it's
32 * indeed an AC3 stream packed in SPDIF frames (i.e. no real AC3 stream).
33 */
34
35
36#include <linux/bitops.h>
37#include <linux/init.h>
38#include <linux/list.h>
39#include <linux/slab.h>
40#include <linux/string.h>
Takashi Iwai3ffc1222011-03-21 12:00:00 +010041#include <linux/ctype.h>
Daniel Macke5779992010-03-04 19:46:13 +010042#include <linux/usb.h>
43#include <linux/moduleparam.h>
44#include <linux/mutex.h>
45#include <linux/usb/audio.h>
Daniel Mack7e847892010-03-11 21:13:20 +010046#include <linux/usb/audio-v2.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040047#include <linux/module.h>
Daniel Macke5779992010-03-04 19:46:13 +010048
Daniel Mack9e386582011-05-25 09:09:01 +020049#include <sound/control.h>
Daniel Macke5779992010-03-04 19:46:13 +010050#include <sound/core.h>
51#include <sound/info.h>
52#include <sound/pcm.h>
53#include <sound/pcm_params.h>
54#include <sound/initval.h>
55
56#include "usbaudio.h"
57#include "card.h"
58#include "midi.h"
Daniel Mackf0b5e632010-03-11 21:13:23 +010059#include "mixer.h"
Daniel Macke5779992010-03-04 19:46:13 +010060#include "proc.h"
61#include "quirks.h"
62#include "endpoint.h"
63#include "helper.h"
64#include "debug.h"
65#include "pcm.h"
Daniel Macke5779992010-03-04 19:46:13 +010066#include "format.h"
Oliver Neukum88a85162011-03-11 14:51:12 +010067#include "power.h"
Daniel Macke8e8bab2011-09-12 18:54:12 +020068#include "stream.h"
Daniel Macke5779992010-03-04 19:46:13 +010069
70MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
71MODULE_DESCRIPTION("USB Audio");
72MODULE_LICENSE("GPL");
73MODULE_SUPPORTED_DEVICE("{{Generic,USB Audio}}");
74
75
76static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
77static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
Rusty Russella67ff6a2011-12-15 13:49:36 +103078static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
Daniel Macke5779992010-03-04 19:46:13 +010079/* Vendor/product IDs for this card */
80static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
81static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
Daniel Macke5779992010-03-04 19:46:13 +010082static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
Rusty Russella67ff6a2011-12-15 13:49:36 +103083static bool ignore_ctl_error;
Eldad Zackef02e292013-04-03 23:18:56 +020084static bool autoclock = true;
Takashi Iwaie2703362016-01-11 14:39:12 +010085static char *quirk_alias[SNDRV_CARDS];
Daniel Macke5779992010-03-04 19:46:13 +010086
87module_param_array(index, int, NULL, 0444);
88MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
89module_param_array(id, charp, NULL, 0444);
90MODULE_PARM_DESC(id, "ID string for the USB audio adapter.");
91module_param_array(enable, bool, NULL, 0444);
92MODULE_PARM_DESC(enable, "Enable USB audio adapter.");
93module_param_array(vid, int, NULL, 0444);
94MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
95module_param_array(pid, int, NULL, 0444);
96MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
Daniel Macke5779992010-03-04 19:46:13 +010097module_param_array(device_setup, int, NULL, 0444);
98MODULE_PARM_DESC(device_setup, "Specific device setup (if needed).");
99module_param(ignore_ctl_error, bool, 0444);
100MODULE_PARM_DESC(ignore_ctl_error,
101 "Ignore errors from USB controller for mixer interfaces.");
Eldad Zackef02e292013-04-03 23:18:56 +0200102module_param(autoclock, bool, 0444);
103MODULE_PARM_DESC(autoclock, "Enable auto-clock selection for UAC2 devices (default: yes).");
Takashi Iwaie2703362016-01-11 14:39:12 +0100104module_param_array(quirk_alias, charp, NULL, 0444);
105MODULE_PARM_DESC(quirk_alias, "Quirk aliases, e.g. 0123abcd:5678beef.");
Daniel Macke5779992010-03-04 19:46:13 +0100106
107/*
108 * we keep the snd_usb_audio_t instances by ourselves for merging
109 * the all interfaces on the same card as one sound device.
110 */
111
112static DEFINE_MUTEX(register_mutex);
113static struct snd_usb_audio *usb_chip[SNDRV_CARDS];
114static struct usb_driver usb_audio_driver;
115
Hemant Kumar9d9dac12016-03-07 14:46:31 -0800116struct snd_usb_substream *find_snd_usb_substream(unsigned int card_num,
117 unsigned int pcm_idx, unsigned int direction, struct snd_usb_audio
118 **uchip, void (*disconnect_cb)(struct snd_usb_audio *chip))
119{
120 int idx;
121 struct snd_usb_stream *as;
122 struct snd_usb_substream *subs = NULL;
123 struct snd_usb_audio *chip = NULL;
124
125 mutex_lock(&register_mutex);
126 /*
127 * legacy audio snd card number assignment is dynamic. Hence
128 * search using chip->card->number
129 */
130 for (idx = 0; idx < SNDRV_CARDS; idx++) {
131 if (!usb_chip[idx])
132 continue;
133 if (usb_chip[idx]->card->number == card_num) {
134 chip = usb_chip[idx];
135 break;
136 }
137 }
138
139 if (!chip || atomic_read(&chip->shutdown)) {
140 pr_debug("%s: instance of usb crad # %d does not exist\n",
141 __func__, card_num);
142 goto err;
143 }
144
145 if (pcm_idx >= chip->pcm_devs) {
146 pr_err("%s: invalid pcm dev number %u > %d\n", __func__,
147 pcm_idx, chip->pcm_devs);
148 goto err;
149 }
150
151 if (direction > SNDRV_PCM_STREAM_CAPTURE) {
152 pr_err("%s: invalid direction %u\n", __func__, direction);
153 goto err;
154 }
155
156 list_for_each_entry(as, &chip->pcm_list, list) {
157 if (as->pcm_index == pcm_idx) {
158 subs = &as->substream[direction];
159 if (subs->interface < 0 && !subs->data_endpoint &&
160 !subs->sync_endpoint) {
161 pr_debug("%s: stream disconnected, bail out\n",
162 __func__);
163 subs = NULL;
164 goto err;
165 }
166 goto done;
167 }
168 }
169
170done:
171 chip->card_num = card_num;
172 chip->disconnect_cb = disconnect_cb;
173err:
174 *uchip = chip;
175 if (!subs)
176 pr_debug("%s: substream instance not found\n", __func__);
177 mutex_unlock(&register_mutex);
178 return subs;
179}
180
Daniel Macke5779992010-03-04 19:46:13 +0100181/*
182 * disconnect streams
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100183 * called from usb_audio_disconnect()
Daniel Macke5779992010-03-04 19:46:13 +0100184 */
Takashi Iwaia6cece92014-10-31 11:24:32 +0100185static void snd_usb_stream_disconnect(struct snd_usb_stream *as)
Daniel Macke5779992010-03-04 19:46:13 +0100186{
187 int idx;
Daniel Macke5779992010-03-04 19:46:13 +0100188 struct snd_usb_substream *subs;
189
Daniel Macke5779992010-03-04 19:46:13 +0100190 for (idx = 0; idx < 2; idx++) {
191 subs = &as->substream[idx];
192 if (!subs->num_formats)
Takashi Iwai76195fb2010-09-08 08:27:02 +0200193 continue;
Daniel Macke5779992010-03-04 19:46:13 +0100194 subs->interface = -1;
Daniel Mackedcd3632012-04-12 13:51:12 +0200195 subs->data_endpoint = NULL;
196 subs->sync_endpoint = NULL;
Daniel Macke5779992010-03-04 19:46:13 +0100197 }
198}
199
200static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int interface)
201{
202 struct usb_device *dev = chip->dev;
203 struct usb_host_interface *alts;
204 struct usb_interface_descriptor *altsd;
205 struct usb_interface *iface = usb_ifnum_to_if(dev, interface);
206
207 if (!iface) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100208 dev_err(&dev->dev, "%u:%d : does not exist\n",
209 ctrlif, interface);
Daniel Macke5779992010-03-04 19:46:13 +0100210 return -EINVAL;
211 }
212
Clemens Ladisch342cda292013-06-15 11:21:09 +0200213 alts = &iface->altsetting[0];
214 altsd = get_iface_desc(alts);
215
216 /*
217 * Android with both accessory and audio interfaces enabled gets the
218 * interface numbers wrong.
219 */
220 if ((chip->usb_id == USB_ID(0x18d1, 0x2d04) ||
221 chip->usb_id == USB_ID(0x18d1, 0x2d05)) &&
222 interface == 0 &&
223 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
224 altsd->bInterfaceSubClass == USB_SUBCLASS_VENDOR_SPEC) {
225 interface = 2;
226 iface = usb_ifnum_to_if(dev, interface);
227 if (!iface)
228 return -EINVAL;
229 alts = &iface->altsetting[0];
230 altsd = get_iface_desc(alts);
231 }
232
Daniel Macke5779992010-03-04 19:46:13 +0100233 if (usb_interface_claimed(iface)) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100234 dev_dbg(&dev->dev, "%d:%d: skipping, already claimed\n",
235 ctrlif, interface);
Daniel Macke5779992010-03-04 19:46:13 +0100236 return -EINVAL;
237 }
238
Daniel Macke5779992010-03-04 19:46:13 +0100239 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO ||
240 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) &&
241 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) {
Takashi Iwai79289e22016-01-11 11:33:34 +0100242 int err = __snd_usbmidi_create(chip->card, iface,
243 &chip->midi_list, NULL,
244 chip->usb_id);
Daniel Macke5779992010-03-04 19:46:13 +0100245 if (err < 0) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100246 dev_err(&dev->dev,
247 "%u:%d: cannot create sequencer device\n",
248 ctrlif, interface);
Daniel Macke5779992010-03-04 19:46:13 +0100249 return -EINVAL;
250 }
251 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
252
253 return 0;
254 }
255
256 if ((altsd->bInterfaceClass != USB_CLASS_AUDIO &&
257 altsd->bInterfaceClass != USB_CLASS_VENDOR_SPEC) ||
258 altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIOSTREAMING) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100259 dev_dbg(&dev->dev,
260 "%u:%d: skipping non-supported interface %d\n",
261 ctrlif, interface, altsd->bInterfaceClass);
Daniel Macke5779992010-03-04 19:46:13 +0100262 /* skip non-supported classes */
263 return -EINVAL;
264 }
265
266 if (snd_usb_get_speed(dev) == USB_SPEED_LOW) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100267 dev_err(&dev->dev, "low speed audio streaming not supported\n");
Daniel Macke5779992010-03-04 19:46:13 +0100268 return -EINVAL;
269 }
270
Daniel Macke8e8bab2011-09-12 18:54:12 +0200271 if (! snd_usb_parse_audio_interface(chip, interface)) {
Daniel Macke5779992010-03-04 19:46:13 +0100272 usb_set_interface(dev, interface, 0); /* reset the current interface */
273 usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
Daniel Macke5779992010-03-04 19:46:13 +0100274 }
275
276 return 0;
277}
278
279/*
280 * parse audio control descriptor and create pcm/midi streams
281 */
282static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
283{
284 struct usb_device *dev = chip->dev;
285 struct usb_host_interface *host_iface;
286 struct usb_interface_descriptor *altsd;
Mayank Rana5d05d2b2013-10-18 14:46:36 +0530287 struct usb_interface *usb_iface;
Daniel Macke5779992010-03-04 19:46:13 +0100288 void *control_header;
289 int i, protocol;
290
Mayank Rana5d05d2b2013-10-18 14:46:36 +0530291 usb_iface = usb_ifnum_to_if(dev, ctrlif);
292 if (!usb_iface) {
293 snd_printk(KERN_ERR "%d:%u : does not exist\n",
294 dev->devnum, ctrlif);
295 return -EINVAL;
296 }
297
Daniel Macke5779992010-03-04 19:46:13 +0100298 /* find audiocontrol interface */
Mayank Rana5d05d2b2013-10-18 14:46:36 +0530299 host_iface = &usb_iface->altsetting[0];
300 if (!host_iface) {
301 snd_printk(KERN_ERR "Audio Control interface is not available.");
302 return -EINVAL;
303 }
304
Daniel Macke5779992010-03-04 19:46:13 +0100305 control_header = snd_usb_find_csint_desc(host_iface->extra,
306 host_iface->extralen,
307 NULL, UAC_HEADER);
308 altsd = get_iface_desc(host_iface);
309 protocol = altsd->bInterfaceProtocol;
310
311 if (!control_header) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100312 dev_err(&dev->dev, "cannot find UAC_HEADER\n");
Daniel Macke5779992010-03-04 19:46:13 +0100313 return -EINVAL;
314 }
315
316 switch (protocol) {
Clemens Ladischa2acad82010-09-03 10:53:11 +0200317 default:
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100318 dev_warn(&dev->dev,
319 "unknown interface protocol %#02x, assuming v1\n",
320 protocol);
Clemens Ladischa2acad82010-09-03 10:53:11 +0200321 /* fall through */
322
Daniel Macke5779992010-03-04 19:46:13 +0100323 case UAC_VERSION_1: {
Daniel Mack69da9bc2010-06-16 17:57:28 +0200324 struct uac1_ac_header_descriptor *h1 = control_header;
Daniel Macke5779992010-03-04 19:46:13 +0100325
326 if (!h1->bInCollection) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100327 dev_info(&dev->dev, "skipping empty audio interface (v1)\n");
Daniel Macke5779992010-03-04 19:46:13 +0100328 return -EINVAL;
329 }
330
331 if (h1->bLength < sizeof(*h1) + h1->bInCollection) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100332 dev_err(&dev->dev, "invalid UAC_HEADER (v1)\n");
Daniel Macke5779992010-03-04 19:46:13 +0100333 return -EINVAL;
334 }
335
336 for (i = 0; i < h1->bInCollection; i++)
337 snd_usb_create_stream(chip, ctrlif, h1->baInterfaceNr[i]);
338
339 break;
340 }
341
342 case UAC_VERSION_2: {
Daniel Macke5779992010-03-04 19:46:13 +0100343 struct usb_interface_assoc_descriptor *assoc =
Mayank Rana5d05d2b2013-10-18 14:46:36 +0530344 usb_iface->intf_assoc;
Daniel Macke5779992010-03-04 19:46:13 +0100345 if (!assoc) {
Clemens Ladisch281a6ac2013-03-11 20:15:34 +0100346 /*
347 * Firmware writers cannot count to three. So to find
348 * the IAD on the NuForce UDH-100, also check the next
349 * interface.
350 */
351 struct usb_interface *iface =
352 usb_ifnum_to_if(dev, ctrlif + 1);
353 if (iface &&
354 iface->intf_assoc &&
355 iface->intf_assoc->bFunctionClass == USB_CLASS_AUDIO &&
356 iface->intf_assoc->bFunctionProtocol == UAC_VERSION_2)
357 assoc = iface->intf_assoc;
358 }
359
360 if (!assoc) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100361 dev_err(&dev->dev, "Audio class v2 interfaces need an interface association\n");
Daniel Macke5779992010-03-04 19:46:13 +0100362 return -EINVAL;
363 }
364
Daniel Macke5779992010-03-04 19:46:13 +0100365 for (i = 0; i < assoc->bInterfaceCount; i++) {
366 int intf = assoc->bFirstInterface + i;
367
368 if (intf != ctrlif)
369 snd_usb_create_stream(chip, ctrlif, intf);
370 }
371
372 break;
373 }
Daniel Macke5779992010-03-04 19:46:13 +0100374 }
375
376 return 0;
377}
378
379/*
380 * free the chip instance
381 *
382 * here we have to do not much, since pcm and controls are already freed
383 *
384 */
385
386static int snd_usb_audio_free(struct snd_usb_audio *chip)
387{
Takashi Iwaia6cece92014-10-31 11:24:32 +0100388 struct snd_usb_endpoint *ep, *n;
Takashi Iwai92a586b2014-06-25 14:24:47 +0200389
Takashi Iwaia6cece92014-10-31 11:24:32 +0100390 list_for_each_entry_safe(ep, n, &chip->ep_list, list)
391 snd_usb_endpoint_free(ep);
Takashi Iwai92a586b2014-06-25 14:24:47 +0200392
Hemant Kumar0ef9fbb2016-01-28 11:41:42 -0800393 mutex_destroy(&chip->dev_lock);
Daniel Mack596580d2012-04-12 13:51:10 +0200394 mutex_destroy(&chip->mutex);
Takashi Iwai6ff1a252016-11-14 21:46:47 +0100395 if (!atomic_read(&chip->shutdown))
396 dev_set_drvdata(&chip->dev->dev, NULL);
Daniel Macke5779992010-03-04 19:46:13 +0100397 kfree(chip);
398 return 0;
399}
400
401static int snd_usb_audio_dev_free(struct snd_device *device)
402{
403 struct snd_usb_audio *chip = device->device_data;
404 return snd_usb_audio_free(chip);
405}
406
Daniel Macke5779992010-03-04 19:46:13 +0100407/*
408 * create a chip instance and set its names.
409 */
Takashi Iwai874b8d42014-01-29 14:22:20 +0100410static int snd_usb_audio_create(struct usb_interface *intf,
411 struct usb_device *dev, int idx,
Daniel Macke5779992010-03-04 19:46:13 +0100412 const struct snd_usb_audio_quirk *quirk,
413 struct snd_usb_audio **rchip)
414{
415 struct snd_card *card;
416 struct snd_usb_audio *chip;
417 int err, len;
418 char component[14];
419 static struct snd_device_ops ops = {
420 .dev_free = snd_usb_audio_dev_free,
421 };
422
423 *rchip = NULL;
424
Paul Zimmerman4f4e8f62010-08-13 12:42:07 -0700425 switch (snd_usb_get_speed(dev)) {
426 case USB_SPEED_LOW:
427 case USB_SPEED_FULL:
428 case USB_SPEED_HIGH:
Thomas Pugliesedf3774c2013-10-01 14:32:15 -0500429 case USB_SPEED_WIRELESS:
Paul Zimmerman4f4e8f62010-08-13 12:42:07 -0700430 case USB_SPEED_SUPER:
Oliver Neukum748a1cc2016-05-04 14:18:39 +0200431 case USB_SPEED_SUPER_PLUS:
Paul Zimmerman4f4e8f62010-08-13 12:42:07 -0700432 break;
433 default:
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100434 dev_err(&dev->dev, "unknown device speed %d\n", snd_usb_get_speed(dev));
Daniel Macke5779992010-03-04 19:46:13 +0100435 return -ENXIO;
436 }
437
Takashi Iwai874b8d42014-01-29 14:22:20 +0100438 err = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE,
439 0, &card);
Daniel Macke5779992010-03-04 19:46:13 +0100440 if (err < 0) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100441 dev_err(&dev->dev, "cannot create card instance %d\n", idx);
Daniel Macke5779992010-03-04 19:46:13 +0100442 return err;
443 }
444
445 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
446 if (! chip) {
447 snd_card_free(card);
448 return -ENOMEM;
449 }
450
Daniel Mack596580d2012-04-12 13:51:10 +0200451 mutex_init(&chip->mutex);
Hemant Kumar0ef9fbb2016-01-28 11:41:42 -0800452 mutex_init(&chip->dev_lock);
Takashi Iwai47ab1542015-08-25 16:09:00 +0200453 init_waitqueue_head(&chip->shutdown_wait);
Daniel Macke5779992010-03-04 19:46:13 +0100454 chip->index = idx;
455 chip->dev = dev;
456 chip->card = card;
457 chip->setup = device_setup[idx];
Eldad Zackef02e292013-04-03 23:18:56 +0200458 chip->autoclock = autoclock;
Takashi Iwaia6da4992015-08-26 10:20:59 +0200459 atomic_set(&chip->active, 1); /* avoid autopm during probing */
Takashi Iwai47ab1542015-08-25 16:09:00 +0200460 atomic_set(&chip->usage_count, 0);
461 atomic_set(&chip->shutdown, 0);
Daniel Macke5779992010-03-04 19:46:13 +0100462
463 chip->usb_id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
464 le16_to_cpu(dev->descriptor.idProduct));
465 INIT_LIST_HEAD(&chip->pcm_list);
Daniel Mackedcd3632012-04-12 13:51:12 +0200466 INIT_LIST_HEAD(&chip->ep_list);
Daniel Macke5779992010-03-04 19:46:13 +0100467 INIT_LIST_HEAD(&chip->midi_list);
468 INIT_LIST_HEAD(&chip->mixer_list);
469
470 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
471 snd_usb_audio_free(chip);
472 snd_card_free(card);
473 return err;
474 }
475
476 strcpy(card->driver, "USB-Audio");
477 sprintf(component, "USB%04x:%04x",
478 USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id));
479 snd_component_add(card, component);
480
481 /* retrieve the device string as shortname */
Takashi Iwai3ffc1222011-03-21 12:00:00 +0100482 if (quirk && quirk->product_name && *quirk->product_name) {
Daniel Macke5779992010-03-04 19:46:13 +0100483 strlcpy(card->shortname, quirk->product_name, sizeof(card->shortname));
484 } else {
485 if (!dev->descriptor.iProduct ||
486 usb_string(dev, dev->descriptor.iProduct,
487 card->shortname, sizeof(card->shortname)) <= 0) {
488 /* no name available from anywhere, so use ID */
489 sprintf(card->shortname, "USB Device %#04x:%#04x",
490 USB_ID_VENDOR(chip->usb_id),
491 USB_ID_PRODUCT(chip->usb_id));
492 }
493 }
Takashi Iwaiae366c22014-10-31 11:32:19 +0100494 strim(card->shortname);
Daniel Macke5779992010-03-04 19:46:13 +0100495
496 /* retrieve the vendor and device strings as longname */
Takashi Iwai3ffc1222011-03-21 12:00:00 +0100497 if (quirk && quirk->vendor_name && *quirk->vendor_name) {
Daniel Macke5779992010-03-04 19:46:13 +0100498 len = strlcpy(card->longname, quirk->vendor_name, sizeof(card->longname));
499 } else {
500 if (dev->descriptor.iManufacturer)
501 len = usb_string(dev, dev->descriptor.iManufacturer,
502 card->longname, sizeof(card->longname));
503 else
504 len = 0;
505 /* we don't really care if there isn't any vendor string */
506 }
Takashi Iwai3ffc1222011-03-21 12:00:00 +0100507 if (len > 0) {
Takashi Iwaiae366c22014-10-31 11:32:19 +0100508 strim(card->longname);
Takashi Iwai3ffc1222011-03-21 12:00:00 +0100509 if (*card->longname)
510 strlcat(card->longname, " ", sizeof(card->longname));
511 }
Daniel Macke5779992010-03-04 19:46:13 +0100512
513 strlcat(card->longname, card->shortname, sizeof(card->longname));
514
515 len = strlcat(card->longname, " at ", sizeof(card->longname));
516
517 if (len < sizeof(card->longname))
518 usb_make_path(dev, card->longname + len, sizeof(card->longname) - len);
519
Paul Zimmerman4f4e8f62010-08-13 12:42:07 -0700520 switch (snd_usb_get_speed(dev)) {
521 case USB_SPEED_LOW:
522 strlcat(card->longname, ", low speed", sizeof(card->longname));
523 break;
524 case USB_SPEED_FULL:
525 strlcat(card->longname, ", full speed", sizeof(card->longname));
526 break;
527 case USB_SPEED_HIGH:
528 strlcat(card->longname, ", high speed", sizeof(card->longname));
529 break;
530 case USB_SPEED_SUPER:
531 strlcat(card->longname, ", super speed", sizeof(card->longname));
532 break;
Oliver Neukum748a1cc2016-05-04 14:18:39 +0200533 case USB_SPEED_SUPER_PLUS:
534 strlcat(card->longname, ", super speed plus", sizeof(card->longname));
535 break;
Paul Zimmerman4f4e8f62010-08-13 12:42:07 -0700536 default:
537 break;
538 }
Daniel Macke5779992010-03-04 19:46:13 +0100539
540 snd_usb_audio_create_proc(chip);
541
542 *rchip = chip;
543 return 0;
544}
545
Takashi Iwaie2703362016-01-11 14:39:12 +0100546/* look for a matching quirk alias id */
547static bool get_alias_id(struct usb_device *dev, unsigned int *id)
548{
549 int i;
550 unsigned int src, dst;
551
552 for (i = 0; i < ARRAY_SIZE(quirk_alias); i++) {
553 if (!quirk_alias[i] ||
554 sscanf(quirk_alias[i], "%x:%x", &src, &dst) != 2 ||
555 src != *id)
556 continue;
557 dev_info(&dev->dev,
558 "device (%04x:%04x): applying quirk alias %04x:%04x\n",
559 USB_ID_VENDOR(*id), USB_ID_PRODUCT(*id),
560 USB_ID_VENDOR(dst), USB_ID_PRODUCT(dst));
561 *id = dst;
562 return true;
563 }
564
565 return false;
566}
567
568static struct usb_device_id usb_audio_ids[]; /* defined below */
569
570/* look for the corresponding quirk */
571static const struct snd_usb_audio_quirk *
572get_alias_quirk(struct usb_device *dev, unsigned int id)
573{
574 const struct usb_device_id *p;
575
576 for (p = usb_audio_ids; p->match_flags; p++) {
577 /* FIXME: this checks only vendor:product pair in the list */
578 if ((p->match_flags & USB_DEVICE_ID_MATCH_DEVICE) ==
579 USB_DEVICE_ID_MATCH_DEVICE &&
580 p->idVendor == USB_ID_VENDOR(id) &&
581 p->idProduct == USB_ID_PRODUCT(id))
582 return (const struct snd_usb_audio_quirk *)p->driver_info;
583 }
584
585 return NULL;
586}
587
Daniel Macke5779992010-03-04 19:46:13 +0100588/*
589 * probe the active usb device
590 *
591 * note that this can be called multiple times per a device, when it
592 * includes multiple audio control interfaces.
593 *
594 * thus we check the usb device pointer and creates the card instance
595 * only at the first time. the successive calls of this function will
596 * append the pcm interface to the corresponding card.
597 */
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100598static int usb_audio_probe(struct usb_interface *intf,
599 const struct usb_device_id *usb_id)
Daniel Macke5779992010-03-04 19:46:13 +0100600{
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100601 struct usb_device *dev = interface_to_usbdev(intf);
602 const struct snd_usb_audio_quirk *quirk =
603 (const struct snd_usb_audio_quirk *)usb_id->driver_info;
Daniel Macke5779992010-03-04 19:46:13 +0100604 struct snd_usb_audio *chip;
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100605 int i, err;
Daniel Macke5779992010-03-04 19:46:13 +0100606 struct usb_host_interface *alts;
607 int ifnum;
608 u32 id;
609
610 alts = &intf->altsetting[0];
611 ifnum = get_iface_desc(alts)->bInterfaceNumber;
612 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
613 le16_to_cpu(dev->descriptor.idProduct));
Takashi Iwaie2703362016-01-11 14:39:12 +0100614 if (get_alias_id(dev, &id))
615 quirk = get_alias_quirk(dev, id);
Daniel Macke5779992010-03-04 19:46:13 +0100616 if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum)
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100617 return -ENXIO;
Daniel Macke5779992010-03-04 19:46:13 +0100618
Takashi Iwai79289e22016-01-11 11:33:34 +0100619 err = snd_usb_apply_boot_quirk(dev, intf, quirk, id);
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100620 if (err < 0)
621 return err;
Daniel Macke5779992010-03-04 19:46:13 +0100622
623 /*
624 * found a config. now register to ALSA
625 */
626
627 /* check whether it's already registered */
628 chip = NULL;
629 mutex_lock(&register_mutex);
630 for (i = 0; i < SNDRV_CARDS; i++) {
631 if (usb_chip[i] && usb_chip[i]->dev == dev) {
Takashi Iwai47ab1542015-08-25 16:09:00 +0200632 if (atomic_read(&usb_chip[i]->shutdown)) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100633 dev_err(&dev->dev, "USB device is in the shutdown state, cannot create a card instance\n");
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100634 err = -EIO;
Daniel Macke5779992010-03-04 19:46:13 +0100635 goto __error;
636 }
637 chip = usb_chip[i];
Takashi Iwaia6da4992015-08-26 10:20:59 +0200638 atomic_inc(&chip->active); /* avoid autopm */
Daniel Macke5779992010-03-04 19:46:13 +0100639 break;
640 }
641 }
642 if (! chip) {
643 /* it's a fresh one.
644 * now look for an empty slot and create a new card instance
645 */
646 for (i = 0; i < SNDRV_CARDS; i++)
647 if (enable[i] && ! usb_chip[i] &&
648 (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&
649 (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100650 err = snd_usb_audio_create(intf, dev, i, quirk,
651 &chip);
652 if (err < 0)
Daniel Macke5779992010-03-04 19:46:13 +0100653 goto __error;
Oliver Neukum88a85162011-03-11 14:51:12 +0100654 chip->pm_intf = intf;
Daniel Macke5779992010-03-04 19:46:13 +0100655 break;
656 }
657 if (!chip) {
Takashi Iwai0ba41d92014-02-26 13:02:17 +0100658 dev_err(&dev->dev, "no available usb audio device\n");
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100659 err = -ENODEV;
Daniel Macke5779992010-03-04 19:46:13 +0100660 goto __error;
661 }
662 }
Kazuki Oikawa76df5292016-07-18 01:16:15 +0900663 dev_set_drvdata(&dev->dev, chip);
Daniel Macke5779992010-03-04 19:46:13 +0100664
Daniel Mack7b6717e2010-09-02 17:13:15 +0800665 /*
666 * For devices with more than one control interface, we assume the
667 * first contains the audio controls. We might need a more specific
668 * check here in the future.
669 */
670 if (!chip->ctrl_intf)
671 chip->ctrl_intf = alts;
Daniel Mack79f920f2010-05-31 14:51:31 +0200672
Daniel Mack5875c2c2011-05-25 09:08:59 +0200673 chip->txfr_quirk = 0;
674 err = 1; /* continue */
675 if (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) {
676 /* need some special handlings */
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100677 err = snd_usb_create_quirk(chip, intf, &usb_audio_driver, quirk);
678 if (err < 0)
Daniel Mack5875c2c2011-05-25 09:08:59 +0200679 goto __error;
680 }
681
Daniel Macke5779992010-03-04 19:46:13 +0100682 if (err > 0) {
683 /* create normal USB audio interfaces */
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100684 err = snd_usb_create_streams(chip, ifnum);
685 if (err < 0)
Daniel Macke5779992010-03-04 19:46:13 +0100686 goto __error;
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100687 err = snd_usb_create_mixer(chip, ifnum, ignore_ctl_error);
688 if (err < 0)
689 goto __error;
Daniel Macke5779992010-03-04 19:46:13 +0100690 }
691
692 /* we are allowed to call snd_card_register() many times */
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100693 err = snd_card_register(chip->card);
694 if (err < 0)
Daniel Macke5779992010-03-04 19:46:13 +0100695 goto __error;
Daniel Macke5779992010-03-04 19:46:13 +0100696
697 usb_chip[chip->index] = chip;
698 chip->num_interfaces++;
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100699 usb_set_intfdata(intf, chip);
Hemant Kumarb3e2d642016-04-01 19:13:01 -0700700 usb_enable_autosuspend(chip->dev);
Takashi Iwaia6da4992015-08-26 10:20:59 +0200701 atomic_dec(&chip->active);
Daniel Macke5779992010-03-04 19:46:13 +0100702 mutex_unlock(&register_mutex);
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100703 return 0;
Daniel Macke5779992010-03-04 19:46:13 +0100704
705 __error:
Thomas Pfaff61a6a102011-09-26 15:43:59 +0200706 if (chip) {
707 if (!chip->num_interfaces)
708 snd_card_free(chip->card);
Takashi Iwaia6da4992015-08-26 10:20:59 +0200709 atomic_dec(&chip->active);
Thomas Pfaff61a6a102011-09-26 15:43:59 +0200710 }
Daniel Macke5779992010-03-04 19:46:13 +0100711 mutex_unlock(&register_mutex);
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100712 return err;
Daniel Macke5779992010-03-04 19:46:13 +0100713}
714
715/*
716 * we need to take care of counter, since disconnection can be called also
717 * many times as well as usb_audio_probe().
718 */
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100719static void usb_audio_disconnect(struct usb_interface *intf)
Daniel Macke5779992010-03-04 19:46:13 +0100720{
Takashi Iwai4c8c3a42014-10-31 11:00:23 +0100721 struct snd_usb_audio *chip = usb_get_intfdata(intf);
Daniel Macke5779992010-03-04 19:46:13 +0100722 struct snd_card *card;
Takashi Iwai92a586b2014-06-25 14:24:47 +0200723 struct list_head *p;
Daniel Macke5779992010-03-04 19:46:13 +0100724
Pavel Roskin81b85b62011-07-06 11:20:13 -0400725 if (chip == (void *)-1L)
Daniel Macke5779992010-03-04 19:46:13 +0100726 return;
727
Daniel Macke5779992010-03-04 19:46:13 +0100728 card = chip->card;
Takashi Iwai10e44232012-11-13 11:22:48 +0100729
Vamsi Krishna Samavedam1e634532016-09-13 14:09:37 -0700730 if (chip->disconnect_cb)
731 chip->disconnect_cb(chip);
732
Takashi Iwai10e44232012-11-13 11:22:48 +0100733 mutex_lock(&register_mutex);
Takashi Iwai47ab1542015-08-25 16:09:00 +0200734 if (atomic_inc_return(&chip->shutdown) == 1) {
Takashi Iwaia6cece92014-10-31 11:24:32 +0100735 struct snd_usb_stream *as;
Takashi Iwai92a586b2014-06-25 14:24:47 +0200736 struct snd_usb_endpoint *ep;
Takashi Iwaia6cece92014-10-31 11:24:32 +0100737 struct usb_mixer_interface *mixer;
Takashi Iwai92a586b2014-06-25 14:24:47 +0200738
Takashi Iwai47ab1542015-08-25 16:09:00 +0200739 /* wait until all pending tasks done;
740 * they are protected by snd_usb_lock_shutdown()
741 */
742 wait_event(chip->shutdown_wait,
743 !atomic_read(&chip->usage_count));
Daniel Macke5779992010-03-04 19:46:13 +0100744 snd_card_disconnect(card);
745 /* release the pcm resources */
Takashi Iwaia6cece92014-10-31 11:24:32 +0100746 list_for_each_entry(as, &chip->pcm_list, list) {
747 snd_usb_stream_disconnect(as);
Daniel Macke5779992010-03-04 19:46:13 +0100748 }
Daniel Mackedcd3632012-04-12 13:51:12 +0200749 /* release the endpoint resources */
Takashi Iwai92a586b2014-06-25 14:24:47 +0200750 list_for_each_entry(ep, &chip->ep_list, list) {
751 snd_usb_endpoint_release(ep);
Daniel Mackedcd3632012-04-12 13:51:12 +0200752 }
Daniel Macke5779992010-03-04 19:46:13 +0100753 /* release the midi resources */
754 list_for_each(p, &chip->midi_list) {
755 snd_usbmidi_disconnect(p);
756 }
757 /* release mixer resources */
Takashi Iwaia6cece92014-10-31 11:24:32 +0100758 list_for_each_entry(mixer, &chip->mixer_list, list) {
759 snd_usb_mixer_disconnect(mixer);
Daniel Macke5779992010-03-04 19:46:13 +0100760 }
Takashi Iwai0725dda2014-11-05 15:08:49 +0100761 }
762
763 chip->num_interfaces--;
764 if (chip->num_interfaces <= 0) {
Daniel Macke5779992010-03-04 19:46:13 +0100765 usb_chip[chip->index] = NULL;
766 mutex_unlock(&register_mutex);
767 snd_card_free_when_closed(card);
768 } else {
769 mutex_unlock(&register_mutex);
770 }
771}
772
Takashi Iwai47ab1542015-08-25 16:09:00 +0200773/* lock the shutdown (disconnect) task and autoresume */
774int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
775{
776 int err;
777
778 atomic_inc(&chip->usage_count);
779 if (atomic_read(&chip->shutdown)) {
780 err = -EIO;
781 goto error;
782 }
783 err = snd_usb_autoresume(chip);
784 if (err < 0)
785 goto error;
786 return 0;
787
788 error:
789 if (atomic_dec_and_test(&chip->usage_count))
790 wake_up(&chip->shutdown_wait);
791 return err;
792}
793
794/* autosuspend and unlock the shutdown */
795void snd_usb_unlock_shutdown(struct snd_usb_audio *chip)
796{
797 snd_usb_autosuspend(chip);
798 if (atomic_dec_and_test(&chip->usage_count))
799 wake_up(&chip->shutdown_wait);
800}
801
Daniel Macke5779992010-03-04 19:46:13 +0100802#ifdef CONFIG_PM
Oliver Neukum88a85162011-03-11 14:51:12 +0100803
804int snd_usb_autoresume(struct snd_usb_audio *chip)
805{
Takashi Iwai47ab1542015-08-25 16:09:00 +0200806 if (atomic_read(&chip->shutdown))
807 return -EIO;
Takashi Iwai47ab1542015-08-25 16:09:00 +0200808 if (atomic_inc_return(&chip->active) == 1)
809 return usb_autopm_get_interface(chip->pm_intf);
810 return 0;
Oliver Neukum88a85162011-03-11 14:51:12 +0100811}
812
813void snd_usb_autosuspend(struct snd_usb_audio *chip)
814{
Takashi Iwai5c06d682016-01-12 14:03:33 +0100815 if (atomic_read(&chip->shutdown))
816 return;
Takashi Iwai47ab1542015-08-25 16:09:00 +0200817 if (atomic_dec_and_test(&chip->active))
Oliver Neukum88a85162011-03-11 14:51:12 +0100818 usb_autopm_put_interface(chip->pm_intf);
819}
820
Daniel Macke5779992010-03-04 19:46:13 +0100821static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
822{
823 struct snd_usb_audio *chip = usb_get_intfdata(intf);
Daniel Macke5779992010-03-04 19:46:13 +0100824 struct snd_usb_stream *as;
Oliver Neukumedf7de32011-03-11 13:19:43 +0100825 struct usb_mixer_interface *mixer;
Adam Goodef7881e52014-08-05 12:44:50 -0400826 struct list_head *p;
Daniel Macke5779992010-03-04 19:46:13 +0100827
828 if (chip == (void *)-1L)
829 return 0;
830
Takashi Iwai06622922015-08-26 10:23:26 +0200831 chip->autosuspended = !!PMSG_IS_AUTO(message);
832 if (!chip->autosuspended)
Oliver Neukum88a85162011-03-11 14:51:12 +0100833 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
Takashi Iwai06622922015-08-26 10:23:26 +0200834 if (!chip->num_suspended_intf++) {
835 list_for_each_entry(as, &chip->pcm_list, list) {
836 snd_pcm_suspend_all(as->pcm);
837 as->substream[0].need_setup_ep =
838 as->substream[1].need_setup_ep = true;
Antonio Ospiteaa53f982013-01-29 12:56:30 +0100839 }
Takashi Iwai06622922015-08-26 10:23:26 +0200840 list_for_each(p, &chip->midi_list)
841 snd_usbmidi_suspend(p);
Takashi Iwai1c53e722014-05-02 18:14:42 +0200842 list_for_each_entry(mixer, &chip->mixer_list, list)
843 snd_usb_mixer_suspend(mixer);
Takashi Iwai06622922015-08-26 10:23:26 +0200844 }
Oliver Neukum88a85162011-03-11 14:51:12 +0100845
Daniel Macke5779992010-03-04 19:46:13 +0100846 return 0;
847}
848
Takashi Iwai400362f2014-01-20 16:51:16 +0100849static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
Daniel Macke5779992010-03-04 19:46:13 +0100850{
851 struct snd_usb_audio *chip = usb_get_intfdata(intf);
Oliver Neukumedf7de32011-03-11 13:19:43 +0100852 struct usb_mixer_interface *mixer;
Adam Goodef7881e52014-08-05 12:44:50 -0400853 struct list_head *p;
Oliver Neukum88a85162011-03-11 14:51:12 +0100854 int err = 0;
Daniel Macke5779992010-03-04 19:46:13 +0100855
856 if (chip == (void *)-1L)
857 return 0;
858 if (--chip->num_suspended_intf)
859 return 0;
Takashi Iwai1ee23fe2014-05-02 18:17:06 +0200860
Takashi Iwai47ab1542015-08-25 16:09:00 +0200861 atomic_inc(&chip->active); /* avoid autopm */
Daniel Macke5779992010-03-04 19:46:13 +0100862 /*
863 * ALSA leaves material resumption to user space
Oliver Neukumedf7de32011-03-11 13:19:43 +0100864 * we just notify and restart the mixers
Daniel Macke5779992010-03-04 19:46:13 +0100865 */
Oliver Neukum88a85162011-03-11 14:51:12 +0100866 list_for_each_entry(mixer, &chip->mixer_list, list) {
Takashi Iwai400362f2014-01-20 16:51:16 +0100867 err = snd_usb_mixer_resume(mixer, reset_resume);
Oliver Neukum88a85162011-03-11 14:51:12 +0100868 if (err < 0)
869 goto err_out;
870 }
Daniel Macke5779992010-03-04 19:46:13 +0100871
Adam Goodef7881e52014-08-05 12:44:50 -0400872 list_for_each(p, &chip->midi_list) {
873 snd_usbmidi_resume(p);
874 }
875
Oliver Neukum88a85162011-03-11 14:51:12 +0100876 if (!chip->autosuspended)
877 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
878 chip->autosuspended = 0;
Daniel Macke5779992010-03-04 19:46:13 +0100879
Oliver Neukum88a85162011-03-11 14:51:12 +0100880err_out:
Takashi Iwai47ab1542015-08-25 16:09:00 +0200881 atomic_dec(&chip->active); /* allow autopm after this point */
Oliver Neukum88a85162011-03-11 14:51:12 +0100882 return err;
Daniel Macke5779992010-03-04 19:46:13 +0100883}
Takashi Iwai400362f2014-01-20 16:51:16 +0100884
885static int usb_audio_resume(struct usb_interface *intf)
886{
887 return __usb_audio_resume(intf, false);
888}
889
890static int usb_audio_reset_resume(struct usb_interface *intf)
891{
892 return __usb_audio_resume(intf, true);
893}
Randy Dunlap6407d472010-03-22 08:55:35 -0700894#else
895#define usb_audio_suspend NULL
896#define usb_audio_resume NULL
Takashi Iwai400362f2014-01-20 16:51:16 +0100897#define usb_audio_reset_resume NULL
Daniel Macke5779992010-03-04 19:46:13 +0100898#endif /* CONFIG_PM */
899
900static struct usb_device_id usb_audio_ids [] = {
901#include "quirks-table.h"
902 { .match_flags = (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS),
903 .bInterfaceClass = USB_CLASS_AUDIO,
904 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL },
905 { } /* Terminating entry */
906};
Eldad Zackf9d35432013-04-03 23:18:50 +0200907MODULE_DEVICE_TABLE(usb, usb_audio_ids);
Daniel Macke5779992010-03-04 19:46:13 +0100908
909/*
910 * entry point for linux usb interface
911 */
912
913static struct usb_driver usb_audio_driver = {
914 .name = "snd-usb-audio",
915 .probe = usb_audio_probe,
916 .disconnect = usb_audio_disconnect,
917 .suspend = usb_audio_suspend,
918 .resume = usb_audio_resume,
Takashi Iwai400362f2014-01-20 16:51:16 +0100919 .reset_resume = usb_audio_reset_resume,
Daniel Macke5779992010-03-04 19:46:13 +0100920 .id_table = usb_audio_ids,
Oliver Neukum88a85162011-03-11 14:51:12 +0100921 .supports_autosuspend = 1,
Daniel Macke5779992010-03-04 19:46:13 +0100922};
923
Sachin Kamat6b5a7c62013-10-09 17:22:32 +0530924module_usb_driver(usb_audio_driver);