aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/Kconfig3
-rw-r--r--sound/usb/caiaq/caiaq-audio.c15
-rw-r--r--sound/usb/caiaq/caiaq-control.c42
-rw-r--r--sound/usb/caiaq/caiaq-device.c46
-rw-r--r--sound/usb/caiaq/caiaq-device.h6
-rw-r--r--sound/usb/usbaudio.c85
-rw-r--r--sound/usb/usbmixer.c164
-rw-r--r--sound/usb/usbmixer_maps.c26
-rw-r--r--sound/usb/usbquirks.h10
-rw-r--r--sound/usb/usx2y/us122l.c59
-rw-r--r--sound/usb/usx2y/usX2Yhwdep.c15
-rw-r--r--sound/usb/usx2y/usb_stream.c2
-rw-r--r--sound/usb/usx2y/usbusx2y.c56
-rw-r--r--sound/usb/usx2y/usx2yhwdeppcm.h2
14 files changed, 322 insertions, 209 deletions
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index 4f0eac9bff1e..523aec188ccf 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -48,7 +48,10 @@ config SND_USB_CAIAQ
48 * Native Instruments Kore Controller 48 * Native Instruments Kore Controller
49 * Native Instruments Kore Controller 2 49 * Native Instruments Kore Controller 2
50 * Native Instruments Audio Kontrol 1 50 * Native Instruments Audio Kontrol 1
51 * Native Instruments Audio 4 DJ
51 * Native Instruments Audio 8 DJ 52 * Native Instruments Audio 8 DJ
53 * Native Instruments Guitar Rig Session I/O
54 * Native Instruments Guitar Rig mobile
52 55
53 To compile this driver as a module, choose M here: the module 56 To compile this driver as a module, choose M here: the module
54 will be called snd-usb-caiaq. 57 will be called snd-usb-caiaq.
diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/caiaq-audio.c
index b3a603325835..08d51e0c9fea 100644
--- a/sound/usb/caiaq/caiaq-audio.c
+++ b/sound/usb/caiaq/caiaq-audio.c
@@ -114,6 +114,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev)
114 dev->output_panic = 0; 114 dev->output_panic = 0;
115 dev->first_packet = 1; 115 dev->first_packet = 1;
116 dev->streaming = 1; 116 dev->streaming = 1;
117 dev->warned = 0;
117 118
118 for (i = 0; i < N_URBS; i++) { 119 for (i = 0; i < N_URBS; i++) {
119 ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC); 120 ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC);
@@ -376,6 +377,9 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
376 377
377 for (stream = 0; stream < dev->n_streams; stream++, i++) { 378 for (stream = 0; stream < dev->n_streams; stream++, i++) {
378 sub = dev->sub_capture[stream]; 379 sub = dev->sub_capture[stream];
380 if (dev->input_panic)
381 usb_buf[i] = 0;
382
379 if (sub) { 383 if (sub) {
380 struct snd_pcm_runtime *rt = sub->runtime; 384 struct snd_pcm_runtime *rt = sub->runtime;
381 char *audio_buf = rt->dma_area; 385 char *audio_buf = rt->dma_area;
@@ -397,6 +401,9 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
397 if (!dev->streaming) 401 if (!dev->streaming)
398 return; 402 return;
399 403
404 if (iso->actual_length < dev->bpp)
405 return;
406
400 switch (dev->spec.data_alignment) { 407 switch (dev->spec.data_alignment) {
401 case 0: 408 case 0:
402 read_in_urb_mode0(dev, urb, iso); 409 read_in_urb_mode0(dev, urb, iso);
@@ -406,10 +413,11 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
406 break; 413 break;
407 } 414 }
408 415
409 if (dev->input_panic || dev->output_panic) { 416 if ((dev->input_panic || dev->output_panic) && !dev->warned) {
410 debug("streaming error detected %s %s\n", 417 debug("streaming error detected %s %s\n",
411 dev->input_panic ? "(input)" : "", 418 dev->input_panic ? "(input)" : "",
412 dev->output_panic ? "(output)" : ""); 419 dev->output_panic ? "(output)" : "");
420 dev->warned = 1;
413 } 421 }
414} 422}
415 423
@@ -638,9 +646,10 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
638 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): 646 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
639 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): 647 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
640 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): 648 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO):
641 dev->samplerates |= SNDRV_PCM_RATE_88200; 649 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE):
642 dev->samplerates |= SNDRV_PCM_RATE_192000; 650 dev->samplerates |= SNDRV_PCM_RATE_192000;
643 break; 651 /* fall thru */
652 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
644 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): 653 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
645 dev->samplerates |= SNDRV_PCM_RATE_88200; 654 dev->samplerates |= SNDRV_PCM_RATE_88200;
646 break; 655 break;
diff --git a/sound/usb/caiaq/caiaq-control.c b/sound/usb/caiaq/caiaq-control.c
index ccd763dd7167..e92c2bbf4fe9 100644
--- a/sound/usb/caiaq/caiaq-control.c
+++ b/sound/usb/caiaq/caiaq-control.c
@@ -39,12 +39,12 @@ static int control_info(struct snd_kcontrol *kcontrol,
39 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); 39 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
40 int pos = kcontrol->private_value; 40 int pos = kcontrol->private_value;
41 int is_intval = pos & CNT_INTVAL; 41 int is_intval = pos & CNT_INTVAL;
42 unsigned int id = dev->chip.usb_id;
42 43
43 uinfo->count = 1; 44 uinfo->count = 1;
44 pos &= ~CNT_INTVAL; 45 pos &= ~CNT_INTVAL;
45 46
46 if (dev->chip.usb_id == 47 if (id == USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)
47 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)
48 && (pos == 0)) { 48 && (pos == 0)) {
49 /* current input mode of A8DJ */ 49 /* current input mode of A8DJ */
50 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 50 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -53,6 +53,15 @@ static int control_info(struct snd_kcontrol *kcontrol,
53 return 0; 53 return 0;
54 } 54 }
55 55
56 if (id == USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)
57 && (pos == 0)) {
58 /* current input mode of A4DJ */
59 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
60 uinfo->value.integer.min = 0;
61 uinfo->value.integer.max = 1;
62 return 0;
63 }
64
56 if (is_intval) { 65 if (is_intval) {
57 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 66 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
58 uinfo->value.integer.min = 0; 67 uinfo->value.integer.min = 0;
@@ -73,6 +82,14 @@ static int control_get(struct snd_kcontrol *kcontrol,
73 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); 82 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
74 int pos = kcontrol->private_value; 83 int pos = kcontrol->private_value;
75 84
85 if (dev->chip.usb_id ==
86 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)) {
87 /* A4DJ has only one control */
88 /* do not expose hardware input mode 0 */
89 ucontrol->value.integer.value[0] = dev->control_state[0] - 1;
90 return 0;
91 }
92
76 if (pos & CNT_INTVAL) 93 if (pos & CNT_INTVAL)
77 ucontrol->value.integer.value[0] 94 ucontrol->value.integer.value[0]
78 = dev->control_state[pos & ~CNT_INTVAL]; 95 = dev->control_state[pos & ~CNT_INTVAL];
@@ -90,10 +107,20 @@ static int control_put(struct snd_kcontrol *kcontrol,
90 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); 107 struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
91 int pos = kcontrol->private_value; 108 int pos = kcontrol->private_value;
92 109
110 if (dev->chip.usb_id ==
111 USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)) {
112 /* A4DJ has only one control */
113 /* do not expose hardware input mode 0 */
114 dev->control_state[0] = ucontrol->value.integer.value[0] + 1;
115 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
116 dev->control_state, sizeof(dev->control_state));
117 return 1;
118 }
119
93 if (pos & CNT_INTVAL) { 120 if (pos & CNT_INTVAL) {
94 dev->control_state[pos & ~CNT_INTVAL] 121 dev->control_state[pos & ~CNT_INTVAL]
95 = ucontrol->value.integer.value[0]; 122 = ucontrol->value.integer.value[0];
96 snd_usb_caiaq_send_command(dev, EP1_CMD_DIMM_LEDS, 123 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
97 dev->control_state, sizeof(dev->control_state)); 124 dev->control_state, sizeof(dev->control_state));
98 } else { 125 } else {
99 if (ucontrol->value.integer.value[0]) 126 if (ucontrol->value.integer.value[0])
@@ -243,10 +270,13 @@ static struct caiaq_controller a8dj_controller[] = {
243 { "GND lift for TC Vinyl mode", 24 + 0 }, 270 { "GND lift for TC Vinyl mode", 24 + 0 },
244 { "GND lift for TC CD/Line mode", 24 + 1 }, 271 { "GND lift for TC CD/Line mode", 24 + 1 },
245 { "GND lift for phono mode", 24 + 2 }, 272 { "GND lift for phono mode", 24 + 2 },
246 { "GND lift for TC Vinyl mode", 24 + 3 },
247 { "Software lock", 40 } 273 { "Software lock", 40 }
248}; 274};
249 275
276static struct caiaq_controller a4dj_controller[] = {
277 { "Current input mode", 0 | CNT_INTVAL }
278};
279
250static int __devinit add_controls(struct caiaq_controller *c, int num, 280static int __devinit add_controls(struct caiaq_controller *c, int num,
251 struct snd_usb_caiaqdev *dev) 281 struct snd_usb_caiaqdev *dev)
252{ 282{
@@ -295,6 +325,10 @@ int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev)
295 ret = add_controls(a8dj_controller, 325 ret = add_controls(a8dj_controller,
296 ARRAY_SIZE(a8dj_controller), dev); 326 ARRAY_SIZE(a8dj_controller), dev);
297 break; 327 break;
328 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
329 ret = add_controls(a4dj_controller,
330 ARRAY_SIZE(a4dj_controller), dev);
331 break;
298 } 332 }
299 333
300 return ret; 334 return ret;
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
index 41c36b055f6b..cf573a982fdc 100644
--- a/sound/usb/caiaq/caiaq-device.c
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -42,15 +42,17 @@
42#endif 42#endif
43 43
44MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 44MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
45MODULE_DESCRIPTION("caiaq USB audio, version 1.3.10"); 45MODULE_DESCRIPTION("caiaq USB audio, version 1.3.13");
46MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
47MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 47MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
48 "{Native Instruments, RigKontrol3}," 48 "{Native Instruments, RigKontrol3},"
49 "{Native Instruments, Kore Controller}," 49 "{Native Instruments, Kore Controller},"
50 "{Native Instruments, Kore Controller 2}," 50 "{Native Instruments, Kore Controller 2},"
51 "{Native Instruments, Audio Kontrol 1}," 51 "{Native Instruments, Audio Kontrol 1},"
52 "{Native Instruments, Audio 4 DJ},"
52 "{Native Instruments, Audio 8 DJ}," 53 "{Native Instruments, Audio 8 DJ},"
53 "{Native Instruments, Session I/O}}"); 54 "{Native Instruments, Session I/O},"
55 "{Native Instruments, GuitarRig mobile}");
54 56
55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */ 57static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
56static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */ 58static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
@@ -116,6 +118,16 @@ static struct usb_device_id snd_usb_id_table[] = {
116 .idVendor = USB_VID_NATIVEINSTRUMENTS, 118 .idVendor = USB_VID_NATIVEINSTRUMENTS,
117 .idProduct = USB_PID_SESSIONIO 119 .idProduct = USB_PID_SESSIONIO
118 }, 120 },
121 {
122 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
123 .idVendor = USB_VID_NATIVEINSTRUMENTS,
124 .idProduct = USB_PID_GUITARRIGMOBILE
125 },
126 {
127 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
128 .idVendor = USB_VID_NATIVEINSTRUMENTS,
129 .idProduct = USB_PID_AUDIO4DJ
130 },
119 { /* terminator */ } 131 { /* terminator */ }
120}; 132};
121 133
@@ -239,6 +251,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
239 251
240 if (dev->audio_parm_answer != 1) 252 if (dev->audio_parm_answer != 1)
241 debug("unable to set the device's audio params\n"); 253 debug("unable to set the device's audio params\n");
254 else
255 dev->bpp = bpp;
242 256
243 return dev->audio_parm_answer == 1 ? 0 : -EINVAL; 257 return dev->audio_parm_answer == 1 ? 0 : -EINVAL;
244} 258}
@@ -300,6 +314,12 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
300 } 314 }
301 315
302 break; 316 break;
317 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
318 /* Audio 4 DJ - default input mode to phono */
319 dev->control_state[0] = 2;
320 snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
321 dev->control_state, 1);
322 break;
303 } 323 }
304 324
305 if (dev->spec.num_analog_audio_out + 325 if (dev->spec.num_analog_audio_out +
@@ -336,9 +356,10 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
336 log("Unable to set up control system (ret=%d)\n", ret); 356 log("Unable to set up control system (ret=%d)\n", ret);
337} 357}
338 358
339static struct snd_card* create_card(struct usb_device* usb_dev) 359static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
340{ 360{
341 int devnum; 361 int devnum;
362 int err;
342 struct snd_card *card; 363 struct snd_card *card;
343 struct snd_usb_caiaqdev *dev; 364 struct snd_usb_caiaqdev *dev;
344 365
@@ -347,12 +368,12 @@ static struct snd_card* create_card(struct usb_device* usb_dev)
347 break; 368 break;
348 369
349 if (devnum >= SNDRV_CARDS) 370 if (devnum >= SNDRV_CARDS)
350 return NULL; 371 return -ENODEV;
351 372
352 card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, 373 err = snd_card_create(index[devnum], id[devnum], THIS_MODULE,
353 sizeof(struct snd_usb_caiaqdev)); 374 sizeof(struct snd_usb_caiaqdev), &card);
354 if (!card) 375 if (err < 0)
355 return NULL; 376 return err;
356 377
357 dev = caiaqdev(card); 378 dev = caiaqdev(card);
358 dev->chip.dev = usb_dev; 379 dev->chip.dev = usb_dev;
@@ -362,7 +383,8 @@ static struct snd_card* create_card(struct usb_device* usb_dev)
362 spin_lock_init(&dev->spinlock); 383 spin_lock_init(&dev->spinlock);
363 snd_card_set_dev(card, &usb_dev->dev); 384 snd_card_set_dev(card, &usb_dev->dev);
364 385
365 return card; 386 *cardp = card;
387 return 0;
366} 388}
367 389
368static int __devinit init_card(struct snd_usb_caiaqdev *dev) 390static int __devinit init_card(struct snd_usb_caiaqdev *dev)
@@ -441,10 +463,10 @@ static int __devinit snd_probe(struct usb_interface *intf,
441 struct snd_card *card; 463 struct snd_card *card;
442 struct usb_device *device = interface_to_usbdev(intf); 464 struct usb_device *device = interface_to_usbdev(intf);
443 465
444 card = create_card(device); 466 ret = create_card(device, &card);
445 467
446 if (!card) 468 if (ret < 0)
447 return -ENOMEM; 469 return ret;
448 470
449 usb_set_intfdata(intf, card); 471 usb_set_intfdata(intf, card);
450 ret = init_card(caiaqdev(card)); 472 ret = init_card(caiaqdev(card));
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/caiaq-device.h
index ab56e738c5fc..4cce1ad7493d 100644
--- a/sound/usb/caiaq/caiaq-device.h
+++ b/sound/usb/caiaq/caiaq-device.h
@@ -10,8 +10,10 @@
10#define USB_PID_KORECONTROLLER 0x4711 10#define USB_PID_KORECONTROLLER 0x4711
11#define USB_PID_KORECONTROLLER2 0x4712 11#define USB_PID_KORECONTROLLER2 0x4712
12#define USB_PID_AK1 0x0815 12#define USB_PID_AK1 0x0815
13#define USB_PID_AUDIO4DJ 0x0839
13#define USB_PID_AUDIO8DJ 0x1978 14#define USB_PID_AUDIO8DJ 0x1978
14#define USB_PID_SESSIONIO 0x1915 15#define USB_PID_SESSIONIO 0x1915
16#define USB_PID_GUITARRIGMOBILE 0x0d8d
15 17
16#define EP1_BUFSIZE 64 18#define EP1_BUFSIZE 64
17#define CAIAQ_USB_STR_LEN 0xff 19#define CAIAQ_USB_STR_LEN 0xff
@@ -87,9 +89,9 @@ struct snd_usb_caiaqdev {
87 int audio_out_buf_pos[MAX_STREAMS]; 89 int audio_out_buf_pos[MAX_STREAMS];
88 int period_in_count[MAX_STREAMS]; 90 int period_in_count[MAX_STREAMS];
89 int period_out_count[MAX_STREAMS]; 91 int period_out_count[MAX_STREAMS];
90 int input_panic, output_panic; 92 int input_panic, output_panic, warned;
91 char *audio_in_buf, *audio_out_buf; 93 char *audio_in_buf, *audio_out_buf;
92 unsigned int samplerates; 94 unsigned int samplerates, bpp;
93 95
94 struct snd_pcm_substream *sub_playback[MAX_STREAMS]; 96 struct snd_pcm_substream *sub_playback[MAX_STREAMS];
95 struct snd_pcm_substream *sub_capture[MAX_STREAMS]; 97 struct snd_pcm_substream *sub_capture[MAX_STREAMS];
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 19e37451c216..c2db0f959681 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -107,7 +107,7 @@ MODULE_PARM_DESC(ignore_ctl_error,
107#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ 107#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */
108#define MAX_URBS 8 108#define MAX_URBS 8
109#define SYNC_URBS 4 /* always four urbs for sync */ 109#define SYNC_URBS 4 /* always four urbs for sync */
110#define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ 110#define MAX_QUEUE 24 /* try not to exceed this queue length, in ms */
111 111
112struct audioformat { 112struct audioformat {
113 struct list_head list; 113 struct list_head list;
@@ -525,7 +525,7 @@ static int snd_usb_audio_next_packet_size(struct snd_usb_substream *subs)
525/* 525/*
526 * Prepare urb for streaming before playback starts or when paused. 526 * Prepare urb for streaming before playback starts or when paused.
527 * 527 *
528 * We don't have any data, so we send a frame of silence. 528 * We don't have any data, so we send silence.
529 */ 529 */
530static int prepare_nodata_playback_urb(struct snd_usb_substream *subs, 530static int prepare_nodata_playback_urb(struct snd_usb_substream *subs,
531 struct snd_pcm_runtime *runtime, 531 struct snd_pcm_runtime *runtime,
@@ -537,13 +537,13 @@ static int prepare_nodata_playback_urb(struct snd_usb_substream *subs,
537 537
538 offs = 0; 538 offs = 0;
539 urb->dev = ctx->subs->dev; 539 urb->dev = ctx->subs->dev;
540 urb->number_of_packets = subs->packs_per_ms; 540 for (i = 0; i < ctx->packets; ++i) {
541 for (i = 0; i < subs->packs_per_ms; ++i) {
542 counts = snd_usb_audio_next_packet_size(subs); 541 counts = snd_usb_audio_next_packet_size(subs);
543 urb->iso_frame_desc[i].offset = offs * stride; 542 urb->iso_frame_desc[i].offset = offs * stride;
544 urb->iso_frame_desc[i].length = counts * stride; 543 urb->iso_frame_desc[i].length = counts * stride;
545 offs += counts; 544 offs += counts;
546 } 545 }
546 urb->number_of_packets = ctx->packets;
547 urb->transfer_buffer_length = offs * stride; 547 urb->transfer_buffer_length = offs * stride;
548 memset(urb->transfer_buffer, 548 memset(urb->transfer_buffer,
549 subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0, 549 subs->cur_audiofmt->format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0,
@@ -1034,9 +1034,9 @@ static void release_substream_urbs(struct snd_usb_substream *subs, int force)
1034static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes, 1034static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes,
1035 unsigned int rate, unsigned int frame_bits) 1035 unsigned int rate, unsigned int frame_bits)
1036{ 1036{
1037 unsigned int maxsize, n, i; 1037 unsigned int maxsize, i;
1038 int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK; 1038 int is_playback = subs->direction == SNDRV_PCM_STREAM_PLAYBACK;
1039 unsigned int npacks[MAX_URBS], urb_packs, total_packs, packs_per_ms; 1039 unsigned int urb_packs, total_packs, packs_per_ms;
1040 1040
1041 /* calculate the frequency in 16.16 format */ 1041 /* calculate the frequency in 16.16 format */
1042 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) 1042 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL)
@@ -1070,8 +1070,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1070 subs->packs_per_ms = packs_per_ms; 1070 subs->packs_per_ms = packs_per_ms;
1071 1071
1072 if (is_playback) { 1072 if (is_playback) {
1073 urb_packs = nrpacks; 1073 urb_packs = max(nrpacks, 1);
1074 urb_packs = max(urb_packs, (unsigned int)MIN_PACKS_URB);
1075 urb_packs = min(urb_packs, (unsigned int)MAX_PACKS); 1074 urb_packs = min(urb_packs, (unsigned int)MAX_PACKS);
1076 } else 1075 } else
1077 urb_packs = 1; 1076 urb_packs = 1;
@@ -1079,7 +1078,7 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1079 1078
1080 /* decide how many packets to be used */ 1079 /* decide how many packets to be used */
1081 if (is_playback) { 1080 if (is_playback) {
1082 unsigned int minsize; 1081 unsigned int minsize, maxpacks;
1083 /* determine how small a packet can be */ 1082 /* determine how small a packet can be */
1084 minsize = (subs->freqn >> (16 - subs->datainterval)) 1083 minsize = (subs->freqn >> (16 - subs->datainterval))
1085 * (frame_bits >> 3); 1084 * (frame_bits >> 3);
@@ -1092,8 +1091,13 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1092 total_packs = (total_packs + packs_per_ms - 1) 1091 total_packs = (total_packs + packs_per_ms - 1)
1093 & ~(packs_per_ms - 1); 1092 & ~(packs_per_ms - 1);
1094 /* we need at least two URBs for queueing */ 1093 /* we need at least two URBs for queueing */
1095 if (total_packs < 2 * MIN_PACKS_URB * packs_per_ms) 1094 if (total_packs < 2 * packs_per_ms) {
1096 total_packs = 2 * MIN_PACKS_URB * packs_per_ms; 1095 total_packs = 2 * packs_per_ms;
1096 } else {
1097 /* and we don't want too long a queue either */
1098 maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2);
1099 total_packs = min(total_packs, maxpacks);
1100 }
1097 } else { 1101 } else {
1098 total_packs = MAX_URBS * urb_packs; 1102 total_packs = MAX_URBS * urb_packs;
1099 } 1103 }
@@ -1102,31 +1106,11 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1102 /* too much... */ 1106 /* too much... */
1103 subs->nurbs = MAX_URBS; 1107 subs->nurbs = MAX_URBS;
1104 total_packs = MAX_URBS * urb_packs; 1108 total_packs = MAX_URBS * urb_packs;
1105 } 1109 } else if (subs->nurbs < 2) {
1106 n = total_packs;
1107 for (i = 0; i < subs->nurbs; i++) {
1108 npacks[i] = n > urb_packs ? urb_packs : n;
1109 n -= urb_packs;
1110 }
1111 if (subs->nurbs <= 1) {
1112 /* too little - we need at least two packets 1110 /* too little - we need at least two packets
1113 * to ensure contiguous playback/capture 1111 * to ensure contiguous playback/capture
1114 */ 1112 */
1115 subs->nurbs = 2; 1113 subs->nurbs = 2;
1116 npacks[0] = (total_packs + 1) / 2;
1117 npacks[1] = total_packs - npacks[0];
1118 } else if (npacks[subs->nurbs-1] < MIN_PACKS_URB * packs_per_ms) {
1119 /* the last packet is too small.. */
1120 if (subs->nurbs > 2) {
1121 /* merge to the first one */
1122 npacks[0] += npacks[subs->nurbs - 1];
1123 subs->nurbs--;
1124 } else {
1125 /* divide to two */
1126 subs->nurbs = 2;
1127 npacks[0] = (total_packs + 1) / 2;
1128 npacks[1] = total_packs - npacks[0];
1129 }
1130 } 1114 }
1131 1115
1132 /* allocate and initialize data urbs */ 1116 /* allocate and initialize data urbs */
@@ -1134,7 +1118,8 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri
1134 struct snd_urb_ctx *u = &subs->dataurb[i]; 1118 struct snd_urb_ctx *u = &subs->dataurb[i];
1135 u->index = i; 1119 u->index = i;
1136 u->subs = subs; 1120 u->subs = subs;
1137 u->packets = npacks[i]; 1121 u->packets = (i + 1) * total_packs / subs->nurbs
1122 - i * total_packs / subs->nurbs;
1138 u->buffer_size = maxsize * u->packets; 1123 u->buffer_size = maxsize * u->packets;
1139 if (subs->fmt_type == USB_FORMAT_TYPE_II) 1124 if (subs->fmt_type == USB_FORMAT_TYPE_II)
1140 u->packets++; /* for transfer delimiter */ 1125 u->packets++; /* for transfer delimiter */
@@ -1292,14 +1277,14 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface,
1292 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR, 1277 if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
1293 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, 1278 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
1294 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1279 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
1295 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n", 1280 snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n",
1296 dev->devnum, iface, fmt->altsetting, rate, ep); 1281 dev->devnum, iface, fmt->altsetting, rate, ep);
1297 return err; 1282 return err;
1298 } 1283 }
1299 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR, 1284 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR,
1300 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, 1285 USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
1301 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) { 1286 SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
1302 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep 0x%x\n", 1287 snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n",
1303 dev->devnum, iface, fmt->altsetting, ep); 1288 dev->devnum, iface, fmt->altsetting, ep);
1304 return 0; /* some devices don't support reading */ 1289 return 0; /* some devices don't support reading */
1305 } 1290 }
@@ -1431,9 +1416,11 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1431 subs->cur_audiofmt = fmt; 1416 subs->cur_audiofmt = fmt;
1432 1417
1433#if 0 1418#if 0
1434 printk("setting done: format = %d, rate = %d..%d, channels = %d\n", 1419 printk(KERN_DEBUG
1420 "setting done: format = %d, rate = %d..%d, channels = %d\n",
1435 fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels); 1421 fmt->format, fmt->rate_min, fmt->rate_max, fmt->channels);
1436 printk(" datapipe = 0x%0x, syncpipe = 0x%0x\n", 1422 printk(KERN_DEBUG
1423 " datapipe = 0x%0x, syncpipe = 0x%0x\n",
1437 subs->datapipe, subs->syncpipe); 1424 subs->datapipe, subs->syncpipe);
1438#endif 1425#endif
1439 1426
@@ -1468,7 +1455,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
1468 channels = params_channels(hw_params); 1455 channels = params_channels(hw_params);
1469 fmt = find_format(subs, format, rate, channels); 1456 fmt = find_format(subs, format, rate, channels);
1470 if (!fmt) { 1457 if (!fmt) {
1471 snd_printd(KERN_DEBUG "cannot set format: format = 0x%x, rate = %d, channels = %d\n", 1458 snd_printd(KERN_DEBUG "cannot set format: format = %#x, rate = %d, channels = %d\n",
1472 format, rate, channels); 1459 format, rate, channels);
1473 return -EINVAL; 1460 return -EINVAL;
1474 } 1461 }
@@ -1795,7 +1782,7 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
1795 if (rates[f->format] && rates[f->format] != f->rates) 1782 if (rates[f->format] && rates[f->format] != f->rates)
1796 goto __out; 1783 goto __out;
1797 } 1784 }
1798 channels[f->format] |= (1 << f->channels); 1785 channels[f->format] |= 1 << (f->channels - 1);
1799 rates[f->format] |= f->rates; 1786 rates[f->format] |= f->rates;
1800 /* needs knot? */ 1787 /* needs knot? */
1801 if (f->rates & SNDRV_PCM_RATE_KNOT) 1788 if (f->rates & SNDRV_PCM_RATE_KNOT)
@@ -1822,7 +1809,7 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
1822 continue; 1809 continue;
1823 for (i = 0; i < 32; i++) { 1810 for (i = 0; i < 32; i++) {
1824 if (f->rates & (1 << i)) 1811 if (f->rates & (1 << i))
1825 channels[i] |= (1 << f->channels); 1812 channels[i] |= 1 << (f->channels - 1);
1826 } 1813 }
1827 } 1814 }
1828 cmaster = 0; 1815 cmaster = 0;
@@ -1919,7 +1906,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1919 * in the current code assume the 1ms period. 1906 * in the current code assume the 1ms period.
1920 */ 1907 */
1921 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1908 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1922 1000 * MIN_PACKS_URB, 1909 1000,
1923 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); 1910 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX);
1924 1911
1925 err = check_hw_params_convention(subs); 1912 err = check_hw_params_convention(subs);
@@ -2160,7 +2147,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2160 fp = list_entry(p, struct audioformat, list); 2147 fp = list_entry(p, struct audioformat, list);
2161 snd_iprintf(buffer, " Interface %d\n", fp->iface); 2148 snd_iprintf(buffer, " Interface %d\n", fp->iface);
2162 snd_iprintf(buffer, " Altset %d\n", fp->altsetting); 2149 snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
2163 snd_iprintf(buffer, " Format: 0x%x\n", fp->format); 2150 snd_iprintf(buffer, " Format: %#x\n", fp->format);
2164 snd_iprintf(buffer, " Channels: %d\n", fp->channels); 2151 snd_iprintf(buffer, " Channels: %d\n", fp->channels);
2165 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", 2152 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n",
2166 fp->endpoint & USB_ENDPOINT_NUMBER_MASK, 2153 fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
@@ -2180,7 +2167,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2180 snd_iprintf(buffer, "\n"); 2167 snd_iprintf(buffer, "\n");
2181 } 2168 }
2182 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); 2169 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize);
2183 // snd_iprintf(buffer, " EP Attribute = 0x%x\n", fp->attributes); 2170 // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes);
2184 } 2171 }
2185} 2172}
2186 2173
@@ -2621,7 +2608,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat
2621 fp->format = SNDRV_PCM_FORMAT_MPEG; 2608 fp->format = SNDRV_PCM_FORMAT_MPEG;
2622 break; 2609 break;
2623 default: 2610 default:
2624 snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected. processed as MPEG.\n", 2611 snd_printd(KERN_INFO "%d:%u:%d : unknown format tag %#x is detected. processed as MPEG.\n",
2625 chip->dev->devnum, fp->iface, fp->altsetting, format); 2612 chip->dev->devnum, fp->iface, fp->altsetting, format);
2626 fp->format = SNDRV_PCM_FORMAT_MPEG; 2613 fp->format = SNDRV_PCM_FORMAT_MPEG;
2627 break; 2614 break;
@@ -2819,7 +2806,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2819 continue; 2806 continue;
2820 } 2807 }
2821 2808
2822 snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint 0x%x\n", dev->devnum, iface_no, altno, fp->endpoint); 2809 snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint %#x\n", dev->devnum, iface_no, altno, fp->endpoint);
2823 err = add_audio_endpoint(chip, stream, fp); 2810 err = add_audio_endpoint(chip, stream, fp);
2824 if (err < 0) { 2811 if (err < 0) {
2825 kfree(fp->rate_table); 2812 kfree(fp->rate_table);
@@ -3466,10 +3453,10 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
3466 return -ENXIO; 3453 return -ENXIO;
3467 } 3454 }
3468 3455
3469 card = snd_card_new(index[idx], id[idx], THIS_MODULE, 0); 3456 err = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card);
3470 if (card == NULL) { 3457 if (err < 0) {
3471 snd_printk(KERN_ERR "cannot create card instance %d\n", idx); 3458 snd_printk(KERN_ERR "cannot create card instance %d\n", idx);
3472 return -ENOMEM; 3459 return err;
3473 } 3460 }
3474 3461
3475 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 3462 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
@@ -3766,7 +3753,7 @@ static int usb_audio_resume(struct usb_interface *intf)
3766 3753
3767static int __init snd_usb_audio_init(void) 3754static int __init snd_usb_audio_init(void)
3768{ 3755{
3769 if (nrpacks < MIN_PACKS_URB || nrpacks > MAX_PACKS) { 3756 if (nrpacks < 1 || nrpacks > MAX_PACKS) {
3770 printk(KERN_WARNING "invalid nrpacks value.\n"); 3757 printk(KERN_WARNING "invalid nrpacks value.\n");
3771 return -EINVAL; 3758 return -EINVAL;
3772 } 3759 }
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 00397c8a765b..ecb58e7a6245 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -66,6 +66,7 @@ static const struct rc_config {
66 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */ 66 { USB_ID(0x041e, 0x3000), 0, 1, 2, 1, 18, 0x0013 }, /* Extigy */
67 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */ 67 { USB_ID(0x041e, 0x3020), 2, 1, 6, 6, 18, 0x0013 }, /* Audigy 2 NX */
68 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */ 68 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
69 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
69}; 70};
70 71
71struct usb_mixer_interface { 72struct usb_mixer_interface {
@@ -78,7 +79,6 @@ struct usb_mixer_interface {
78 79
79 /* Sound Blaster remote control stuff */ 80 /* Sound Blaster remote control stuff */
80 const struct rc_config *rc_cfg; 81 const struct rc_config *rc_cfg;
81 unsigned long rc_hwdep_open;
82 u32 rc_code; 82 u32 rc_code;
83 wait_queue_head_t rc_waitq; 83 wait_queue_head_t rc_waitq;
84 struct urb *rc_urb; 84 struct urb *rc_urb;
@@ -110,6 +110,8 @@ struct mixer_build {
110 const struct usbmix_selector_map *selector_map; 110 const struct usbmix_selector_map *selector_map;
111}; 111};
112 112
113#define MAX_CHANNELS 10 /* max logical channels */
114
113struct usb_mixer_elem_info { 115struct usb_mixer_elem_info {
114 struct usb_mixer_interface *mixer; 116 struct usb_mixer_interface *mixer;
115 struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */ 117 struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */
@@ -120,6 +122,8 @@ struct usb_mixer_elem_info {
120 int channels; 122 int channels;
121 int val_type; 123 int val_type;
122 int min, max, res; 124 int min, max, res;
125 int cached;
126 int cache_val[MAX_CHANNELS];
123 u8 initialized; 127 u8 initialized;
124}; 128};
125 129
@@ -181,8 +185,6 @@ enum {
181 USB_PROC_DCR_RELEASE = 6, 185 USB_PROC_DCR_RELEASE = 6,
182}; 186};
183 187
184#define MAX_CHANNELS 10 /* max logical channels */
185
186 188
187/* 189/*
188 * manual mapping of mixer names 190 * manual mapping of mixer names
@@ -219,7 +221,10 @@ static int check_ignored_ctl(struct mixer_build *state, int unitid, int control)
219 for (p = state->map; p->id; p++) { 221 for (p = state->map; p->id; p++) {
220 if (p->id == unitid && ! p->name && 222 if (p->id == unitid && ! p->name &&
221 (! control || ! p->control || control == p->control)) { 223 (! control || ! p->control || control == p->control)) {
222 // printk("ignored control %d:%d\n", unitid, control); 224 /*
225 printk(KERN_DEBUG "ignored control %d:%d\n",
226 unitid, control);
227 */
223 return 1; 228 return 1;
224 } 229 }
225 } 230 }
@@ -376,11 +381,35 @@ static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *
376} 381}
377 382
378/* channel = 0: master, 1 = first channel */ 383/* channel = 0: master, 1 = first channel */
379static inline int get_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int *value) 384static inline int get_cur_mix_raw(struct usb_mixer_elem_info *cval,
385 int channel, int *value)
380{ 386{
381 return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); 387 return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value);
382} 388}
383 389
390static int get_cur_mix_value(struct usb_mixer_elem_info *cval,
391 int channel, int index, int *value)
392{
393 int err;
394
395 if (cval->cached & (1 << channel)) {
396 *value = cval->cache_val[index];
397 return 0;
398 }
399 err = get_cur_mix_raw(cval, channel, value);
400 if (err < 0) {
401 if (!cval->mixer->ignore_ctl_error)
402 snd_printd(KERN_ERR "cannot get current value for "
403 "control %d ch %d: err = %d\n",
404 cval->control, channel, err);
405 return err;
406 }
407 cval->cached |= 1 << channel;
408 cval->cache_val[index] = *value;
409 return 0;
410}
411
412
384/* 413/*
385 * set a mixer value 414 * set a mixer value
386 */ 415 */
@@ -412,9 +441,17 @@ static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int v
412 return set_ctl_value(cval, SET_CUR, validx, value); 441 return set_ctl_value(cval, SET_CUR, validx, value);
413} 442}
414 443
415static inline int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int value) 444static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
445 int index, int value)
416{ 446{
417 return set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, value); 447 int err;
448 err = set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel,
449 value);
450 if (err < 0)
451 return err;
452 cval->cached |= 1 << channel;
453 cval->cache_val[index] = value;
454 return 0;
418} 455}
419 456
420/* 457/*
@@ -718,7 +755,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
718 if (cval->min + cval->res < cval->max) { 755 if (cval->min + cval->res < cval->max) {
719 int last_valid_res = cval->res; 756 int last_valid_res = cval->res;
720 int saved, test, check; 757 int saved, test, check;
721 get_cur_mix_value(cval, minchn, &saved); 758 get_cur_mix_raw(cval, minchn, &saved);
722 for (;;) { 759 for (;;) {
723 test = saved; 760 test = saved;
724 if (test < cval->max) 761 if (test < cval->max)
@@ -726,8 +763,8 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
726 else 763 else
727 test -= cval->res; 764 test -= cval->res;
728 if (test < cval->min || test > cval->max || 765 if (test < cval->min || test > cval->max ||
729 set_cur_mix_value(cval, minchn, test) || 766 set_cur_mix_value(cval, minchn, 0, test) ||
730 get_cur_mix_value(cval, minchn, &check)) { 767 get_cur_mix_raw(cval, minchn, &check)) {
731 cval->res = last_valid_res; 768 cval->res = last_valid_res;
732 break; 769 break;
733 } 770 }
@@ -735,7 +772,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min)
735 break; 772 break;
736 cval->res *= 2; 773 cval->res *= 2;
737 } 774 }
738 set_cur_mix_value(cval, minchn, saved); 775 set_cur_mix_value(cval, minchn, 0, saved);
739 } 776 }
740 777
741 cval->initialized = 1; 778 cval->initialized = 1;
@@ -775,35 +812,25 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
775 struct usb_mixer_elem_info *cval = kcontrol->private_data; 812 struct usb_mixer_elem_info *cval = kcontrol->private_data;
776 int c, cnt, val, err; 813 int c, cnt, val, err;
777 814
815 ucontrol->value.integer.value[0] = cval->min;
778 if (cval->cmask) { 816 if (cval->cmask) {
779 cnt = 0; 817 cnt = 0;
780 for (c = 0; c < MAX_CHANNELS; c++) { 818 for (c = 0; c < MAX_CHANNELS; c++) {
781 if (cval->cmask & (1 << c)) { 819 if (!(cval->cmask & (1 << c)))
782 err = get_cur_mix_value(cval, c + 1, &val); 820 continue;
783 if (err < 0) { 821 err = get_cur_mix_value(cval, c + 1, cnt, &val);
784 if (cval->mixer->ignore_ctl_error) { 822 if (err < 0)
785 ucontrol->value.integer.value[0] = cval->min; 823 return cval->mixer->ignore_ctl_error ? 0 : err;
786 return 0; 824 val = get_relative_value(cval, val);
787 } 825 ucontrol->value.integer.value[cnt] = val;
788 snd_printd(KERN_ERR "cannot get current value for control %d ch %d: err = %d\n", cval->control, c + 1, err); 826 cnt++;
789 return err;
790 }
791 val = get_relative_value(cval, val);
792 ucontrol->value.integer.value[cnt] = val;
793 cnt++;
794 }
795 } 827 }
828 return 0;
796 } else { 829 } else {
797 /* master channel */ 830 /* master channel */
798 err = get_cur_mix_value(cval, 0, &val); 831 err = get_cur_mix_value(cval, 0, 0, &val);
799 if (err < 0) { 832 if (err < 0)
800 if (cval->mixer->ignore_ctl_error) { 833 return cval->mixer->ignore_ctl_error ? 0 : err;
801 ucontrol->value.integer.value[0] = cval->min;
802 return 0;
803 }
804 snd_printd(KERN_ERR "cannot get current value for control %d master ch: err = %d\n", cval->control, err);
805 return err;
806 }
807 val = get_relative_value(cval, val); 834 val = get_relative_value(cval, val);
808 ucontrol->value.integer.value[0] = val; 835 ucontrol->value.integer.value[0] = val;
809 } 836 }
@@ -820,34 +847,28 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
820 if (cval->cmask) { 847 if (cval->cmask) {
821 cnt = 0; 848 cnt = 0;
822 for (c = 0; c < MAX_CHANNELS; c++) { 849 for (c = 0; c < MAX_CHANNELS; c++) {
823 if (cval->cmask & (1 << c)) { 850 if (!(cval->cmask & (1 << c)))
824 err = get_cur_mix_value(cval, c + 1, &oval); 851 continue;
825 if (err < 0) { 852 err = get_cur_mix_value(cval, c + 1, cnt, &oval);
826 if (cval->mixer->ignore_ctl_error) 853 if (err < 0)
827 return 0; 854 return cval->mixer->ignore_ctl_error ? 0 : err;
828 return err; 855 val = ucontrol->value.integer.value[cnt];
829 } 856 val = get_abs_value(cval, val);
830 val = ucontrol->value.integer.value[cnt]; 857 if (oval != val) {
831 val = get_abs_value(cval, val); 858 set_cur_mix_value(cval, c + 1, cnt, val);
832 if (oval != val) { 859 changed = 1;
833 set_cur_mix_value(cval, c + 1, val);
834 changed = 1;
835 }
836 get_cur_mix_value(cval, c + 1, &val);
837 cnt++;
838 } 860 }
861 cnt++;
839 } 862 }
840 } else { 863 } else {
841 /* master channel */ 864 /* master channel */
842 err = get_cur_mix_value(cval, 0, &oval); 865 err = get_cur_mix_value(cval, 0, 0, &oval);
843 if (err < 0 && cval->mixer->ignore_ctl_error)
844 return 0;
845 if (err < 0) 866 if (err < 0)
846 return err; 867 return cval->mixer->ignore_ctl_error ? 0 : err;
847 val = ucontrol->value.integer.value[0]; 868 val = ucontrol->value.integer.value[0];
848 val = get_abs_value(cval, val); 869 val = get_abs_value(cval, val);
849 if (val != oval) { 870 if (val != oval) {
850 set_cur_mix_value(cval, 0, val); 871 set_cur_mix_value(cval, 0, 0, val);
851 changed = 1; 872 changed = 1;
852 } 873 }
853 } 874 }
@@ -1706,7 +1727,8 @@ static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer,
1706 break; 1727 break;
1707 /* live24ext: 4 = line-in jack */ 1728 /* live24ext: 4 = line-in jack */
1708 case 3: /* hp-out jack (may actuate Mute) */ 1729 case 3: /* hp-out jack (may actuate Mute) */
1709 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 1730 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1731 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1710 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id); 1732 snd_usb_mixer_notify_id(mixer, mixer->rc_cfg->mute_mixer_id);
1711 break; 1733 break;
1712 default: 1734 default:
@@ -1797,24 +1819,6 @@ static void snd_usb_soundblaster_remote_complete(struct urb *urb)
1797 wake_up(&mixer->rc_waitq); 1819 wake_up(&mixer->rc_waitq);
1798} 1820}
1799 1821
1800static int snd_usb_sbrc_hwdep_open(struct snd_hwdep *hw, struct file *file)
1801{
1802 struct usb_mixer_interface *mixer = hw->private_data;
1803
1804 if (test_and_set_bit(0, &mixer->rc_hwdep_open))
1805 return -EBUSY;
1806 return 0;
1807}
1808
1809static int snd_usb_sbrc_hwdep_release(struct snd_hwdep *hw, struct file *file)
1810{
1811 struct usb_mixer_interface *mixer = hw->private_data;
1812
1813 clear_bit(0, &mixer->rc_hwdep_open);
1814 smp_mb__after_clear_bit();
1815 return 0;
1816}
1817
1818static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, 1822static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf,
1819 long count, loff_t *offset) 1823 long count, loff_t *offset)
1820{ 1824{
@@ -1867,9 +1871,8 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
1867 hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC; 1871 hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC;
1868 hwdep->private_data = mixer; 1872 hwdep->private_data = mixer;
1869 hwdep->ops.read = snd_usb_sbrc_hwdep_read; 1873 hwdep->ops.read = snd_usb_sbrc_hwdep_read;
1870 hwdep->ops.open = snd_usb_sbrc_hwdep_open;
1871 hwdep->ops.release = snd_usb_sbrc_hwdep_release;
1872 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; 1874 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
1875 hwdep->exclusive = 1;
1873 1876
1874 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); 1877 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
1875 if (!mixer->rc_urb) 1878 if (!mixer->rc_urb)
@@ -1956,8 +1959,9 @@ static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
1956 int i, err; 1959 int i, err;
1957 1960
1958 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) { 1961 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) {
1959 if (i > 1 && /* Live24ext has 2 LEDs only */ 1962 if (i > 1 && /* Live24ext has 2 LEDs only */
1960 mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 1963 (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
1964 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)))
1961 break; 1965 break;
1962 err = snd_ctl_add(mixer->chip->card, 1966 err = snd_ctl_add(mixer->chip->card,
1963 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer)); 1967 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer));
@@ -1994,7 +1998,8 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
1994 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname); 1998 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
1995 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) 1999 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020))
1996 jacks = jacks_audigy2nx; 2000 jacks = jacks_audigy2nx;
1997 else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) 2001 else if (mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
2002 mixer->chip->usb_id == USB_ID(0x041e, 0x3048))
1998 jacks = jacks_live24ext; 2003 jacks = jacks_live24ext;
1999 else 2004 else
2000 return; 2005 return;
@@ -2044,7 +2049,8 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
2044 goto _error; 2049 goto _error;
2045 2050
2046 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) || 2051 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) ||
2047 mixer->chip->usb_id == USB_ID(0x041e, 0x3040)) { 2052 mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
2053 mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) {
2048 struct snd_info_entry *entry; 2054 struct snd_info_entry *entry;
2049 2055
2050 if ((err = snd_audigy2nx_controls_create(mixer)) < 0) 2056 if ((err = snd_audigy2nx_controls_create(mixer)) < 0)
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c
index d755be0ad811..3e5d66cf1f5a 100644
--- a/sound/usb/usbmixer_maps.c
+++ b/sound/usb/usbmixer_maps.c
@@ -261,6 +261,22 @@ static struct usbmix_name_map aureon_51_2_map[] = {
261 {} /* terminator */ 261 {} /* terminator */
262}; 262};
263 263
264static struct usbmix_name_map scratch_live_map[] = {
265 /* 1: IT Line 1 (USB streaming) */
266 /* 2: OT Line 1 (Speaker) */
267 /* 3: IT Line 1 (Line connector) */
268 { 4, "Line 1 In" }, /* FU */
269 /* 5: OT Line 1 (USB streaming) */
270 /* 6: IT Line 2 (USB streaming) */
271 /* 7: OT Line 2 (Speaker) */
272 /* 8: IT Line 2 (Line connector) */
273 { 9, "Line 2 In" }, /* FU */
274 /* 10: OT Line 2 (USB streaming) */
275 /* 11: IT Mic (Line connector) */
276 /* 12: OT Mic (USB streaming) */
277 { 0 } /* terminator */
278};
279
264/* 280/*
265 * Control map entries 281 * Control map entries
266 */ 282 */
@@ -285,6 +301,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
285 .map = live24ext_map, 301 .map = live24ext_map,
286 }, 302 },
287 { 303 {
304 .id = USB_ID(0x041e, 0x3048),
305 .map = audigy2nx_map,
306 .selector_map = audigy2nx_selectors,
307 },
308 {
288 /* Hercules DJ Console (Windows Edition) */ 309 /* Hercules DJ Console (Windows Edition) */
289 .id = USB_ID(0x06f8, 0xb000), 310 .id = USB_ID(0x06f8, 0xb000),
290 .ignore_ctl_error = 1, 311 .ignore_ctl_error = 1,
@@ -311,6 +332,11 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
311 .id = USB_ID(0x0ccd, 0x0028), 332 .id = USB_ID(0x0ccd, 0x0028),
312 .map = aureon_51_2_map, 333 .map = aureon_51_2_map,
313 }, 334 },
335 {
336 .id = USB_ID(0x13e5, 0x0001),
337 .map = scratch_live_map,
338 .ignore_ctl_error = 1,
339 },
314 { 0 } /* terminator */ 340 { 0 } /* terminator */
315}; 341};
316 342
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 5d8ef09b9dcc..647ef5029651 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -39,6 +39,16 @@
39 .idProduct = prod, \ 39 .idProduct = prod, \
40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC 40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC
41 41
42/* Creative/Toshiba Multimedia Center SB-0500 */
43{
44 USB_DEVICE(0x041e, 0x3048),
45 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
46 .vendor_name = "Toshiba",
47 .product_name = "SB-0500",
48 .ifnum = QUIRK_NO_INTERFACE
49 }
50},
51
42/* Creative/E-Mu devices */ 52/* Creative/E-Mu devices */
43{ 53{
44 USB_DEVICE(0x041e, 0x3010), 54 USB_DEVICE(0x041e, 0x3010),
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 73e59f4403a4..98276aafefe6 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -478,19 +478,21 @@ static bool us122l_create_card(struct snd_card *card)
478 return true; 478 return true;
479} 479}
480 480
481static struct snd_card *usx2y_create_card(struct usb_device *device) 481static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
482{ 482{
483 int dev; 483 int dev;
484 struct snd_card *card; 484 struct snd_card *card;
485 int err;
486
485 for (dev = 0; dev < SNDRV_CARDS; ++dev) 487 for (dev = 0; dev < SNDRV_CARDS; ++dev)
486 if (enable[dev] && !snd_us122l_card_used[dev]) 488 if (enable[dev] && !snd_us122l_card_used[dev])
487 break; 489 break;
488 if (dev >= SNDRV_CARDS) 490 if (dev >= SNDRV_CARDS)
489 return NULL; 491 return -ENODEV;
490 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 492 err = snd_card_create(index[dev], id[dev], THIS_MODULE,
491 sizeof(struct us122l)); 493 sizeof(struct us122l), &card);
492 if (!card) 494 if (err < 0)
493 return NULL; 495 return err;
494 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 496 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1;
495 497
496 US122L(card)->chip.dev = device; 498 US122L(card)->chip.dev = device;
@@ -509,46 +511,57 @@ static struct snd_card *usx2y_create_card(struct usb_device *device)
509 US122L(card)->chip.dev->devnum 511 US122L(card)->chip.dev->devnum
510 ); 512 );
511 snd_card_set_dev(card, &device->dev); 513 snd_card_set_dev(card, &device->dev);
512 return card; 514 *cardp = card;
515 return 0;
513} 516}
514 517
515static void *us122l_usb_probe(struct usb_interface *intf, 518static int us122l_usb_probe(struct usb_interface *intf,
516 const struct usb_device_id *device_id) 519 const struct usb_device_id *device_id,
520 struct snd_card **cardp)
517{ 521{
518 struct usb_device *device = interface_to_usbdev(intf); 522 struct usb_device *device = interface_to_usbdev(intf);
519 struct snd_card *card = usx2y_create_card(device); 523 struct snd_card *card;
524 int err;
520 525
521 if (!card) 526 err = usx2y_create_card(device, &card);
522 return NULL; 527 if (err < 0)
528 return err;
523 529
524 if (!us122l_create_card(card) || 530 if (!us122l_create_card(card)) {
525 snd_card_register(card) < 0) {
526 snd_card_free(card); 531 snd_card_free(card);
527 return NULL; 532 return -EINVAL;
533 }
534
535 err = snd_card_register(card);
536 if (err < 0) {
537 snd_card_free(card);
538 return err;
528 } 539 }
529 540
530 usb_get_dev(device); 541 usb_get_dev(device);
531 return card; 542 *cardp = card;
543 return 0;
532} 544}
533 545
534static int snd_us122l_probe(struct usb_interface *intf, 546static int snd_us122l_probe(struct usb_interface *intf,
535 const struct usb_device_id *id) 547 const struct usb_device_id *id)
536{ 548{
537 struct snd_card *card; 549 struct snd_card *card;
550 int err;
551
538 snd_printdd(KERN_DEBUG"%p:%i\n", 552 snd_printdd(KERN_DEBUG"%p:%i\n",
539 intf, intf->cur_altsetting->desc.bInterfaceNumber); 553 intf, intf->cur_altsetting->desc.bInterfaceNumber);
540 if (intf->cur_altsetting->desc.bInterfaceNumber != 1) 554 if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
541 return 0; 555 return 0;
542 556
543 card = us122l_usb_probe(usb_get_intf(intf), id); 557 err = us122l_usb_probe(usb_get_intf(intf), id, &card);
544 558 if (err < 0) {
545 if (card) { 559 usb_put_intf(intf);
546 usb_set_intfdata(intf, card); 560 return err;
547 return 0;
548 } 561 }
549 562
550 usb_put_intf(intf); 563 usb_set_intfdata(intf, card);
551 return -EIO; 564 return 0;
552} 565}
553 566
554static void snd_us122l_disconnect(struct usb_interface *intf) 567static void snd_us122l_disconnect(struct usb_interface *intf)
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c
index 1558a5c4094f..4af8740db717 100644
--- a/sound/usb/usx2y/usX2Yhwdep.c
+++ b/sound/usb/usx2y/usX2Yhwdep.c
@@ -30,9 +30,6 @@
30#include "usbusx2y.h" 30#include "usbusx2y.h"
31#include "usX2Yhwdep.h" 31#include "usX2Yhwdep.h"
32 32
33int usX2Y_hwdep_pcm_new(struct snd_card *card);
34
35
36static int snd_us428ctls_vm_fault(struct vm_area_struct *area, 33static int snd_us428ctls_vm_fault(struct vm_area_struct *area,
37 struct vm_fault *vmf) 34 struct vm_fault *vmf)
38{ 35{
@@ -106,16 +103,6 @@ static unsigned int snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file,
106} 103}
107 104
108 105
109static int snd_usX2Y_hwdep_open(struct snd_hwdep *hw, struct file *file)
110{
111 return 0;
112}
113
114static int snd_usX2Y_hwdep_release(struct snd_hwdep *hw, struct file *file)
115{
116 return 0;
117}
118
119static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, 106static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw,
120 struct snd_hwdep_dsp_status *info) 107 struct snd_hwdep_dsp_status *info)
121{ 108{
@@ -267,8 +254,6 @@ int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device)
267 254
268 hw->iface = SNDRV_HWDEP_IFACE_USX2Y; 255 hw->iface = SNDRV_HWDEP_IFACE_USX2Y;
269 hw->private_data = usX2Y(card); 256 hw->private_data = usX2Y(card);
270 hw->ops.open = snd_usX2Y_hwdep_open;
271 hw->ops.release = snd_usX2Y_hwdep_release;
272 hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status; 257 hw->ops.dsp_status = snd_usX2Y_hwdep_dsp_status;
273 hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load; 258 hw->ops.dsp_load = snd_usX2Y_hwdep_dsp_load;
274 hw->ops.mmap = snd_us428ctls_mmap; 259 hw->ops.mmap = snd_us428ctls_mmap;
diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
index 70b96355ca4c..24393dafcb6e 100644
--- a/sound/usb/usx2y/usb_stream.c
+++ b/sound/usb/usx2y/usb_stream.c
@@ -557,7 +557,7 @@ static void stream_start(struct usb_stream_kernel *sk,
557 s->idle_insize -= max_diff - max_diff_0; 557 s->idle_insize -= max_diff - max_diff_0;
558 s->idle_insize += urb_size - s->period_size; 558 s->idle_insize += urb_size - s->period_size;
559 if (s->idle_insize < 0) { 559 if (s->idle_insize < 0) {
560 snd_printk("%i %i %i\n", 560 snd_printk(KERN_WARNING "%i %i %i\n",
561 s->idle_insize, urb_size, s->period_size); 561 s->idle_insize, urb_size, s->period_size);
562 return; 562 return;
563 } else if (s->idle_insize == 0) { 563 } else if (s->idle_insize == 0) {
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index 11639bd72a51..5ce0da23ee96 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -227,9 +227,9 @@ static void i_usX2Y_In04Int(struct urb *urb)
227 227
228 if (usX2Y->US04) { 228 if (usX2Y->US04) {
229 if (0 == usX2Y->US04->submitted) 229 if (0 == usX2Y->US04->submitted)
230 do 230 do {
231 err = usb_submit_urb(usX2Y->US04->urb[usX2Y->US04->submitted++], GFP_ATOMIC); 231 err = usb_submit_urb(usX2Y->US04->urb[usX2Y->US04->submitted++], GFP_ATOMIC);
232 while (!err && usX2Y->US04->submitted < usX2Y->US04->len); 232 } while (!err && usX2Y->US04->submitted < usX2Y->US04->len);
233 } else 233 } else
234 if (us428ctls && us428ctls->p4outLast >= 0 && us428ctls->p4outLast < N_us428_p4out_BUFS) { 234 if (us428ctls && us428ctls->p4outLast >= 0 && us428ctls->p4outLast < N_us428_p4out_BUFS) {
235 if (us428ctls->p4outLast != us428ctls->p4outSent) { 235 if (us428ctls->p4outLast != us428ctls->p4outSent) {
@@ -333,18 +333,21 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = {
333 { /* terminator */ } 333 { /* terminator */ }
334}; 334};
335 335
336static struct snd_card *usX2Y_create_card(struct usb_device *device) 336static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
337{ 337{
338 int dev; 338 int dev;
339 struct snd_card * card; 339 struct snd_card * card;
340 int err;
341
340 for (dev = 0; dev < SNDRV_CARDS; ++dev) 342 for (dev = 0; dev < SNDRV_CARDS; ++dev)
341 if (enable[dev] && !snd_usX2Y_card_used[dev]) 343 if (enable[dev] && !snd_usX2Y_card_used[dev])
342 break; 344 break;
343 if (dev >= SNDRV_CARDS) 345 if (dev >= SNDRV_CARDS)
344 return NULL; 346 return -ENODEV;
345 card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct usX2Ydev)); 347 err = snd_card_create(index[dev], id[dev], THIS_MODULE,
346 if (!card) 348 sizeof(struct usX2Ydev), &card);
347 return NULL; 349 if (err < 0)
350 return err;
348 snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; 351 snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1;
349 card->private_free = snd_usX2Y_card_private_free; 352 card->private_free = snd_usX2Y_card_private_free;
350 usX2Y(card)->chip.dev = device; 353 usX2Y(card)->chip.dev = device;
@@ -362,26 +365,36 @@ static struct snd_card *usX2Y_create_card(struct usb_device *device)
362 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum 365 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum
363 ); 366 );
364 snd_card_set_dev(card, &device->dev); 367 snd_card_set_dev(card, &device->dev);
365 return card; 368 *cardp = card;
369 return 0;
366} 370}
367 371
368 372
369static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *intf, const struct usb_device_id *device_id) 373static int usX2Y_usb_probe(struct usb_device *device,
374 struct usb_interface *intf,
375 const struct usb_device_id *device_id,
376 struct snd_card **cardp)
370{ 377{
371 int err; 378 int err;
372 struct snd_card * card; 379 struct snd_card * card;
380
381 *cardp = NULL;
373 if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || 382 if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 ||
374 (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && 383 (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 &&
375 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && 384 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 &&
376 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428) || 385 le16_to_cpu(device->descriptor.idProduct) != USB_ID_US428))
377 !(card = usX2Y_create_card(device))) 386 return -EINVAL;
378 return NULL; 387
388 err = usX2Y_create_card(device, &card);
389 if (err < 0)
390 return err;
379 if ((err = usX2Y_hwdep_new(card, device)) < 0 || 391 if ((err = usX2Y_hwdep_new(card, device)) < 0 ||
380 (err = snd_card_register(card)) < 0) { 392 (err = snd_card_register(card)) < 0) {
381 snd_card_free(card); 393 snd_card_free(card);
382 return NULL; 394 return err;
383 } 395 }
384 return card; 396 *cardp = card;
397 return 0;
385} 398}
386 399
387/* 400/*
@@ -389,13 +402,14 @@ static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *in
389 */ 402 */
390static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_id *id) 403static int snd_usX2Y_probe(struct usb_interface *intf, const struct usb_device_id *id)
391{ 404{
392 void *chip; 405 struct snd_card *card;
393 chip = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id); 406 int err;
394 if (chip) { 407
395 usb_set_intfdata(intf, chip); 408 err = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id, &card);
396 return 0; 409 if (err < 0)
397 } else 410 return err;
398 return -EIO; 411 dev_set_drvdata(&intf->dev, card);
412 return 0;
399} 413}
400 414
401static void snd_usX2Y_disconnect(struct usb_interface *intf) 415static void snd_usX2Y_disconnect(struct usb_interface *intf)
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.h b/sound/usb/usx2y/usx2yhwdeppcm.h
index c3382fdc386b..9c4fb84b2aa0 100644
--- a/sound/usb/usx2y/usx2yhwdeppcm.h
+++ b/sound/usb/usx2y/usx2yhwdeppcm.h
@@ -18,3 +18,5 @@ struct snd_usX2Y_hwdep_pcm_shm {
18 volatile unsigned captured_iso_frames; 18 volatile unsigned captured_iso_frames;
19 int capture_iso_start; 19 int capture_iso_start;
20}; 20};
21
22int usX2Y_hwdep_pcm_new(struct snd_card *card);