aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/Kconfig1
-rw-r--r--sound/usb/caiaq/audio.c94
-rw-r--r--sound/usb/caiaq/device.c123
-rw-r--r--sound/usb/caiaq/device.h2
-rw-r--r--sound/usb/caiaq/midi.c24
-rw-r--r--sound/usb/usbaudio.c57
-rw-r--r--sound/usb/usbmixer.c27
-rw-r--r--sound/usb/usbquirks.h43
-rw-r--r--sound/usb/usx2y/us122l.c2
-rw-r--r--sound/usb/usx2y/usbusx2y.c2
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c7
11 files changed, 253 insertions, 129 deletions
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index 523aec188ccf..73525c048e7f 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -48,6 +48,7 @@ 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 2 DJ
51 * Native Instruments Audio 4 DJ 52 * Native Instruments Audio 4 DJ
52 * Native Instruments Audio 8 DJ 53 * Native Instruments Audio 8 DJ
53 * Native Instruments Guitar Rig Session I/O 54 * Native Instruments Guitar Rig Session I/O
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
index b13ce767ac72..121af0644fd9 100644
--- a/sound/usb/caiaq/audio.c
+++ b/sound/usb/caiaq/audio.c
@@ -42,10 +42,10 @@
42 (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) 42 (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1)
43 43
44static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { 44static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = {
45 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 45 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
46 SNDRV_PCM_INFO_BLOCK_TRANSFER), 46 SNDRV_PCM_INFO_BLOCK_TRANSFER),
47 .formats = SNDRV_PCM_FMTBIT_S24_3BE, 47 .formats = SNDRV_PCM_FMTBIT_S24_3BE,
48 .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | 48 .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
49 SNDRV_PCM_RATE_96000), 49 SNDRV_PCM_RATE_96000),
50 .rate_min = 44100, 50 .rate_min = 44100,
51 .rate_max = 0, /* will overwrite later */ 51 .rate_max = 0, /* will overwrite later */
@@ -68,7 +68,7 @@ activate_substream(struct snd_usb_caiaqdev *dev,
68 dev->sub_capture[sub->number] = sub; 68 dev->sub_capture[sub->number] = sub;
69} 69}
70 70
71static void 71static void
72deactivate_substream(struct snd_usb_caiaqdev *dev, 72deactivate_substream(struct snd_usb_caiaqdev *dev,
73 struct snd_pcm_substream *sub) 73 struct snd_pcm_substream *sub)
74{ 74{
@@ -118,7 +118,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev)
118 return -EPIPE; 118 return -EPIPE;
119 } 119 }
120 } 120 }
121 121
122 return 0; 122 return 0;
123} 123}
124 124
@@ -129,7 +129,7 @@ static void stream_stop(struct snd_usb_caiaqdev *dev)
129 debug("%s(%p)\n", __func__, dev); 129 debug("%s(%p)\n", __func__, dev);
130 if (!dev->streaming) 130 if (!dev->streaming)
131 return; 131 return;
132 132
133 dev->streaming = 0; 133 dev->streaming = 0;
134 134
135 for (i = 0; i < N_URBS; i++) { 135 for (i = 0; i < N_URBS; i++) {
@@ -154,7 +154,7 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
154 debug("%s(%p)\n", __func__, substream); 154 debug("%s(%p)\n", __func__, substream);
155 if (all_substreams_zero(dev->sub_playback) && 155 if (all_substreams_zero(dev->sub_playback) &&
156 all_substreams_zero(dev->sub_capture)) { 156 all_substreams_zero(dev->sub_capture)) {
157 /* when the last client has stopped streaming, 157 /* when the last client has stopped streaming,
158 * all sample rates are allowed again */ 158 * all sample rates are allowed again */
159 stream_stop(dev); 159 stream_stop(dev);
160 dev->pcm_info.rates = dev->samplerates; 160 dev->pcm_info.rates = dev->samplerates;
@@ -194,30 +194,31 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
194 struct snd_pcm_runtime *runtime = substream->runtime; 194 struct snd_pcm_runtime *runtime = substream->runtime;
195 195
196 debug("%s(%p)\n", __func__, substream); 196 debug("%s(%p)\n", __func__, substream);
197 197
198 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 198 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
199 dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; 199 dev->period_out_count[index] = BYTES_PER_SAMPLE + 1;
200 dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; 200 dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1;
201 } else { 201 } else {
202 dev->period_in_count[index] = BYTES_PER_SAMPLE; 202 int in_pos = (dev->spec.data_alignment == 2) ? 0 : 2;
203 dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE; 203 dev->period_in_count[index] = BYTES_PER_SAMPLE + in_pos;
204 dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE + in_pos;
204 } 205 }
205 206
206 if (dev->streaming) 207 if (dev->streaming)
207 return 0; 208 return 0;
208 209
209 /* the first client that opens a stream defines the sample rate 210 /* the first client that opens a stream defines the sample rate
210 * setting for all subsequent calls, until the last client closed. */ 211 * setting for all subsequent calls, until the last client closed. */
211 for (i=0; i < ARRAY_SIZE(rates); i++) 212 for (i=0; i < ARRAY_SIZE(rates); i++)
212 if (runtime->rate == rates[i]) 213 if (runtime->rate == rates[i])
213 dev->pcm_info.rates = 1 << i; 214 dev->pcm_info.rates = 1 << i;
214 215
215 snd_pcm_limit_hw_rates(runtime); 216 snd_pcm_limit_hw_rates(runtime);
216 217
217 bytes_per_sample = BYTES_PER_SAMPLE; 218 bytes_per_sample = BYTES_PER_SAMPLE;
218 if (dev->spec.data_alignment == 2) 219 if (dev->spec.data_alignment == 2)
219 bytes_per_sample++; 220 bytes_per_sample++;
220 221
221 bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) 222 bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE)
222 * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; 223 * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams;
223 224
@@ -232,7 +233,7 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
232 ret = stream_start(dev); 233 ret = stream_start(dev);
233 if (ret) 234 if (ret)
234 return ret; 235 return ret;
235 236
236 dev->output_running = 0; 237 dev->output_running = 0;
237 wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); 238 wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ);
238 if (!dev->output_running) { 239 if (!dev->output_running) {
@@ -273,7 +274,7 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
273 return SNDRV_PCM_POS_XRUN; 274 return SNDRV_PCM_POS_XRUN;
274 275
275 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) 276 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
276 return bytes_to_frames(sub->runtime, 277 return bytes_to_frames(sub->runtime,
277 dev->audio_out_buf_pos[index]); 278 dev->audio_out_buf_pos[index]);
278 else 279 else
279 return bytes_to_frames(sub->runtime, 280 return bytes_to_frames(sub->runtime,
@@ -291,7 +292,7 @@ static struct snd_pcm_ops snd_usb_caiaq_ops = {
291 .trigger = snd_usb_caiaq_pcm_trigger, 292 .trigger = snd_usb_caiaq_pcm_trigger,
292 .pointer = snd_usb_caiaq_pcm_pointer 293 .pointer = snd_usb_caiaq_pcm_pointer
293}; 294};
294 295
295static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, 296static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev,
296 struct snd_pcm_substream **subs) 297 struct snd_pcm_substream **subs)
297{ 298{
@@ -333,7 +334,7 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev,
333 struct snd_pcm_runtime *rt = sub->runtime; 334 struct snd_pcm_runtime *rt = sub->runtime;
334 char *audio_buf = rt->dma_area; 335 char *audio_buf = rt->dma_area;
335 int sz = frames_to_bytes(rt, rt->buffer_size); 336 int sz = frames_to_bytes(rt, rt->buffer_size);
336 audio_buf[dev->audio_in_buf_pos[stream]++] 337 audio_buf[dev->audio_in_buf_pos[stream]++]
337 = usb_buf[i]; 338 = usb_buf[i];
338 dev->period_in_count[stream]++; 339 dev->period_in_count[stream]++;
339 if (dev->audio_in_buf_pos[stream] == sz) 340 if (dev->audio_in_buf_pos[stream] == sz)
@@ -354,14 +355,14 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
354 355
355 for (i = 0; i < iso->actual_length;) { 356 for (i = 0; i < iso->actual_length;) {
356 if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { 357 if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) {
357 for (stream = 0; 358 for (stream = 0;
358 stream < dev->n_streams; 359 stream < dev->n_streams;
359 stream++, i++) { 360 stream++, i++) {
360 if (dev->first_packet) 361 if (dev->first_packet)
361 continue; 362 continue;
362 363
363 check_byte = MAKE_CHECKBYTE(dev, stream, i); 364 check_byte = MAKE_CHECKBYTE(dev, stream, i);
364 365
365 if ((usb_buf[i] & 0x3f) != check_byte) 366 if ((usb_buf[i] & 0x3f) != check_byte)
366 dev->input_panic = 1; 367 dev->input_panic = 1;
367 368
@@ -410,21 +411,21 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
410 } 411 }
411 412
412 if ((dev->input_panic || dev->output_panic) && !dev->warned) { 413 if ((dev->input_panic || dev->output_panic) && !dev->warned) {
413 debug("streaming error detected %s %s\n", 414 debug("streaming error detected %s %s\n",
414 dev->input_panic ? "(input)" : "", 415 dev->input_panic ? "(input)" : "",
415 dev->output_panic ? "(output)" : ""); 416 dev->output_panic ? "(output)" : "");
416 dev->warned = 1; 417 dev->warned = 1;
417 } 418 }
418} 419}
419 420
420static void fill_out_urb(struct snd_usb_caiaqdev *dev, 421static void fill_out_urb(struct snd_usb_caiaqdev *dev,
421 struct urb *urb, 422 struct urb *urb,
422 const struct usb_iso_packet_descriptor *iso) 423 const struct usb_iso_packet_descriptor *iso)
423{ 424{
424 unsigned char *usb_buf = urb->transfer_buffer + iso->offset; 425 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
425 struct snd_pcm_substream *sub; 426 struct snd_pcm_substream *sub;
426 int stream, i; 427 int stream, i;
427 428
428 for (i = 0; i < iso->length;) { 429 for (i = 0; i < iso->length;) {
429 for (stream = 0; stream < dev->n_streams; stream++, i++) { 430 for (stream = 0; stream < dev->n_streams; stream++, i++) {
430 sub = dev->sub_playback[stream]; 431 sub = dev->sub_playback[stream];
@@ -444,7 +445,7 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev,
444 445
445 /* fill in the check bytes */ 446 /* fill in the check bytes */
446 if (dev->spec.data_alignment == 2 && 447 if (dev->spec.data_alignment == 2 &&
447 i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 448 i % (dev->n_streams * BYTES_PER_SAMPLE_USB) ==
448 (dev->n_streams * CHANNELS_PER_STREAM)) 449 (dev->n_streams * CHANNELS_PER_STREAM))
449 for (stream = 0; stream < dev->n_streams; stream++, i++) 450 for (stream = 0; stream < dev->n_streams; stream++, i++)
450 usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); 451 usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i);
@@ -453,7 +454,7 @@ static void fill_out_urb(struct snd_usb_caiaqdev *dev,
453 454
454static void read_completed(struct urb *urb) 455static void read_completed(struct urb *urb)
455{ 456{
456 struct snd_usb_caiaq_cb_info *info = urb->context; 457 struct snd_usb_caiaq_cb_info *info = urb->context;
457 struct snd_usb_caiaqdev *dev; 458 struct snd_usb_caiaqdev *dev;
458 struct urb *out; 459 struct urb *out;
459 int frame, len, send_it = 0, outframe = 0; 460 int frame, len, send_it = 0, outframe = 0;
@@ -478,7 +479,7 @@ static void read_completed(struct urb *urb)
478 out->iso_frame_desc[outframe].length = len; 479 out->iso_frame_desc[outframe].length = len;
479 out->iso_frame_desc[outframe].actual_length = 0; 480 out->iso_frame_desc[outframe].actual_length = 0;
480 out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame; 481 out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame;
481 482
482 if (len > 0) { 483 if (len > 0) {
483 spin_lock(&dev->spinlock); 484 spin_lock(&dev->spinlock);
484 fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); 485 fill_out_urb(dev, out, &out->iso_frame_desc[outframe]);
@@ -497,14 +498,14 @@ static void read_completed(struct urb *urb)
497 out->transfer_flags = URB_ISO_ASAP; 498 out->transfer_flags = URB_ISO_ASAP;
498 usb_submit_urb(out, GFP_ATOMIC); 499 usb_submit_urb(out, GFP_ATOMIC);
499 } 500 }
500 501
501 /* re-submit inbound urb */ 502 /* re-submit inbound urb */
502 for (frame = 0; frame < FRAMES_PER_URB; frame++) { 503 for (frame = 0; frame < FRAMES_PER_URB; frame++) {
503 urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame; 504 urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame;
504 urb->iso_frame_desc[frame].length = BYTES_PER_FRAME; 505 urb->iso_frame_desc[frame].length = BYTES_PER_FRAME;
505 urb->iso_frame_desc[frame].actual_length = 0; 506 urb->iso_frame_desc[frame].actual_length = 0;
506 } 507 }
507 508
508 urb->number_of_packets = FRAMES_PER_URB; 509 urb->number_of_packets = FRAMES_PER_URB;
509 urb->transfer_flags = URB_ISO_ASAP; 510 urb->transfer_flags = URB_ISO_ASAP;
510 usb_submit_urb(urb, GFP_ATOMIC); 511 usb_submit_urb(urb, GFP_ATOMIC);
@@ -528,7 +529,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)
528 struct usb_device *usb_dev = dev->chip.dev; 529 struct usb_device *usb_dev = dev->chip.dev;
529 unsigned int pipe; 530 unsigned int pipe;
530 531
531 pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? 532 pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ?
532 usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) : 533 usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) :
533 usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE); 534 usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE);
534 535
@@ -547,25 +548,25 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)
547 return urbs; 548 return urbs;
548 } 549 }
549 550
550 urbs[i]->transfer_buffer = 551 urbs[i]->transfer_buffer =
551 kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); 552 kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL);
552 if (!urbs[i]->transfer_buffer) { 553 if (!urbs[i]->transfer_buffer) {
553 log("unable to kmalloc() transfer buffer, OOM!?\n"); 554 log("unable to kmalloc() transfer buffer, OOM!?\n");
554 *ret = -ENOMEM; 555 *ret = -ENOMEM;
555 return urbs; 556 return urbs;
556 } 557 }
557 558
558 for (frame = 0; frame < FRAMES_PER_URB; frame++) { 559 for (frame = 0; frame < FRAMES_PER_URB; frame++) {
559 struct usb_iso_packet_descriptor *iso = 560 struct usb_iso_packet_descriptor *iso =
560 &urbs[i]->iso_frame_desc[frame]; 561 &urbs[i]->iso_frame_desc[frame];
561 562
562 iso->offset = BYTES_PER_FRAME * frame; 563 iso->offset = BYTES_PER_FRAME * frame;
563 iso->length = BYTES_PER_FRAME; 564 iso->length = BYTES_PER_FRAME;
564 } 565 }
565 566
566 urbs[i]->dev = usb_dev; 567 urbs[i]->dev = usb_dev;
567 urbs[i]->pipe = pipe; 568 urbs[i]->pipe = pipe;
568 urbs[i]->transfer_buffer_length = FRAMES_PER_URB 569 urbs[i]->transfer_buffer_length = FRAMES_PER_URB
569 * BYTES_PER_FRAME; 570 * BYTES_PER_FRAME;
570 urbs[i]->context = &dev->data_cb_info[i]; 571 urbs[i]->context = &dev->data_cb_info[i];
571 urbs[i]->interval = 1; 572 urbs[i]->interval = 1;
@@ -589,7 +590,7 @@ static void free_urbs(struct urb **urbs)
589 for (i = 0; i < N_URBS; i++) { 590 for (i = 0; i < N_URBS; i++) {
590 if (!urbs[i]) 591 if (!urbs[i])
591 continue; 592 continue;
592 593
593 usb_kill_urb(urbs[i]); 594 usb_kill_urb(urbs[i]);
594 kfree(urbs[i]->transfer_buffer); 595 kfree(urbs[i]->transfer_buffer);
595 usb_free_urb(urbs[i]); 596 usb_free_urb(urbs[i]);
@@ -602,11 +603,11 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
602{ 603{
603 int i, ret; 604 int i, ret;
604 605
605 dev->n_audio_in = max(dev->spec.num_analog_audio_in, 606 dev->n_audio_in = max(dev->spec.num_analog_audio_in,
606 dev->spec.num_digital_audio_in) / 607 dev->spec.num_digital_audio_in) /
607 CHANNELS_PER_STREAM; 608 CHANNELS_PER_STREAM;
608 dev->n_audio_out = max(dev->spec.num_analog_audio_out, 609 dev->n_audio_out = max(dev->spec.num_analog_audio_out,
609 dev->spec.num_digital_audio_out) / 610 dev->spec.num_digital_audio_out) /
610 CHANNELS_PER_STREAM; 611 CHANNELS_PER_STREAM;
611 dev->n_streams = max(dev->n_audio_in, dev->n_audio_out); 612 dev->n_streams = max(dev->n_audio_in, dev->n_audio_out);
612 613
@@ -619,7 +620,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
619 return -EINVAL; 620 return -EINVAL;
620 } 621 }
621 622
622 ret = snd_pcm_new(dev->chip.card, dev->product_name, 0, 623 ret = snd_pcm_new(dev->chip.card, dev->product_name, 0,
623 dev->n_audio_out, dev->n_audio_in, &dev->pcm); 624 dev->n_audio_out, dev->n_audio_in, &dev->pcm);
624 625
625 if (ret < 0) { 626 if (ret < 0) {
@@ -632,7 +633,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
632 633
633 memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); 634 memset(dev->sub_playback, 0, sizeof(dev->sub_playback));
634 memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); 635 memset(dev->sub_capture, 0, sizeof(dev->sub_capture));
635 636
636 memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware, 637 memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware,
637 sizeof(snd_usb_caiaq_pcm_hardware)); 638 sizeof(snd_usb_caiaq_pcm_hardware));
638 639
@@ -645,15 +646,16 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
645 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): 646 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE):
646 dev->samplerates |= SNDRV_PCM_RATE_192000; 647 dev->samplerates |= SNDRV_PCM_RATE_192000;
647 /* fall thru */ 648 /* fall thru */
649 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ):
648 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): 650 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
649 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): 651 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
650 dev->samplerates |= SNDRV_PCM_RATE_88200; 652 dev->samplerates |= SNDRV_PCM_RATE_88200;
651 break; 653 break;
652 } 654 }
653 655
654 snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, 656 snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK,
655 &snd_usb_caiaq_ops); 657 &snd_usb_caiaq_ops);
656 snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, 658 snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE,
657 &snd_usb_caiaq_ops); 659 &snd_usb_caiaq_ops);
658 660
659 snd_pcm_lib_preallocate_pages_for_all(dev->pcm, 661 snd_pcm_lib_preallocate_pages_for_all(dev->pcm,
@@ -662,7 +664,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
662 MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); 664 MAX_BUFFER_SIZE, MAX_BUFFER_SIZE);
663 665
664 dev->data_cb_info = 666 dev->data_cb_info =
665 kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, 667 kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS,
666 GFP_KERNEL); 668 GFP_KERNEL);
667 669
668 if (!dev->data_cb_info) 670 if (!dev->data_cb_info)
@@ -672,14 +674,14 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
672 dev->data_cb_info[i].dev = dev; 674 dev->data_cb_info[i].dev = dev;
673 dev->data_cb_info[i].index = i; 675 dev->data_cb_info[i].index = i;
674 } 676 }
675 677
676 dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret); 678 dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret);
677 if (ret < 0) { 679 if (ret < 0) {
678 kfree(dev->data_cb_info); 680 kfree(dev->data_cb_info);
679 free_urbs(dev->data_urbs_in); 681 free_urbs(dev->data_urbs_in);
680 return ret; 682 return ret;
681 } 683 }
682 684
683 dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret); 685 dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret);
684 if (ret < 0) { 686 if (ret < 0) {
685 kfree(dev->data_cb_info); 687 kfree(dev->data_cb_info);
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 515de1cd2a3e..83e6c1312d47 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -35,13 +35,14 @@
35#include "input.h" 35#include "input.h"
36 36
37MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); 37MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
38MODULE_DESCRIPTION("caiaq USB audio, version 1.3.14"); 38MODULE_DESCRIPTION("caiaq USB audio, version 1.3.19");
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," 40MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
41 "{Native Instruments, RigKontrol3}," 41 "{Native Instruments, RigKontrol3},"
42 "{Native Instruments, Kore Controller}," 42 "{Native Instruments, Kore Controller},"
43 "{Native Instruments, Kore Controller 2}," 43 "{Native Instruments, Kore Controller 2},"
44 "{Native Instruments, Audio Kontrol 1}," 44 "{Native Instruments, Audio Kontrol 1},"
45 "{Native Instruments, Audio 2 DJ},"
45 "{Native Instruments, Audio 4 DJ}," 46 "{Native Instruments, Audio 4 DJ},"
46 "{Native Instruments, Audio 8 DJ}," 47 "{Native Instruments, Audio 8 DJ},"
47 "{Native Instruments, Session I/O}," 48 "{Native Instruments, Session I/O},"
@@ -79,7 +80,7 @@ static struct usb_device_id snd_usb_id_table[] = {
79 { 80 {
80 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 81 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
81 .idVendor = USB_VID_NATIVEINSTRUMENTS, 82 .idVendor = USB_VID_NATIVEINSTRUMENTS,
82 .idProduct = USB_PID_RIGKONTROL2 83 .idProduct = USB_PID_RIGKONTROL2
83 }, 84 },
84 { 85 {
85 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, 86 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
@@ -121,6 +122,11 @@ static struct usb_device_id snd_usb_id_table[] = {
121 .idVendor = USB_VID_NATIVEINSTRUMENTS, 122 .idVendor = USB_VID_NATIVEINSTRUMENTS,
122 .idProduct = USB_PID_AUDIO4DJ 123 .idProduct = USB_PID_AUDIO4DJ
123 }, 124 },
125 {
126 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
127 .idVendor = USB_VID_NATIVEINSTRUMENTS,
128 .idProduct = USB_PID_AUDIO2DJ
129 },
124 { /* terminator */ } 130 { /* terminator */ }
125}; 131};
126 132
@@ -197,7 +203,7 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev,
197 203
198 if (buffer && len > 0) 204 if (buffer && len > 0)
199 memcpy(dev->ep1_out_buf+1, buffer, len); 205 memcpy(dev->ep1_out_buf+1, buffer, len);
200 206
201 dev->ep1_out_buf[0] = command; 207 dev->ep1_out_buf[0] = command;
202 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), 208 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
203 dev->ep1_out_buf, len+1, &actual_len, 200); 209 dev->ep1_out_buf, len+1, &actual_len, 200);
@@ -208,7 +214,7 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
208{ 214{
209 int ret; 215 int ret;
210 char tmp[5]; 216 char tmp[5];
211 217
212 switch (rate) { 218 switch (rate) {
213 case 44100: tmp[0] = SAMPLERATE_44100; break; 219 case 44100: tmp[0] = SAMPLERATE_44100; break;
214 case 48000: tmp[0] = SAMPLERATE_48000; break; 220 case 48000: tmp[0] = SAMPLERATE_48000; break;
@@ -237,12 +243,12 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
237 243
238 if (ret) 244 if (ret)
239 return ret; 245 return ret;
240 246
241 if (!wait_event_timeout(dev->ep1_wait_queue, 247 if (!wait_event_timeout(dev->ep1_wait_queue,
242 dev->audio_parm_answer >= 0, HZ)) 248 dev->audio_parm_answer >= 0, HZ))
243 return -EPIPE; 249 return -EPIPE;
244 250
245 if (dev->audio_parm_answer != 1) 251 if (dev->audio_parm_answer != 1)
246 debug("unable to set the device's audio params\n"); 252 debug("unable to set the device's audio params\n");
247 else 253 else
248 dev->bpp = bpp; 254 dev->bpp = bpp;
@@ -250,8 +256,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
250 return dev->audio_parm_answer == 1 ? 0 : -EINVAL; 256 return dev->audio_parm_answer == 1 ? 0 : -EINVAL;
251} 257}
252 258
253int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, 259int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *dev,
254 int digital, int analog, int erp) 260 int digital, int analog, int erp)
255{ 261{
256 char tmp[3] = { digital, analog, erp }; 262 char tmp[3] = { digital, analog, erp };
257 return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, 263 return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG,
@@ -262,7 +268,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
262{ 268{
263 int ret; 269 int ret;
264 char val[4]; 270 char val[4];
265 271
266 /* device-specific startup specials */ 272 /* device-specific startup specials */
267 switch (dev->chip.usb_id) { 273 switch (dev->chip.usb_id) {
268 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): 274 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
@@ -314,7 +320,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
314 dev->control_state, 1); 320 dev->control_state, 1);
315 break; 321 break;
316 } 322 }
317 323
318 if (dev->spec.num_analog_audio_out + 324 if (dev->spec.num_analog_audio_out +
319 dev->spec.num_analog_audio_in + 325 dev->spec.num_analog_audio_in +
320 dev->spec.num_digital_audio_out + 326 dev->spec.num_digital_audio_out +
@@ -323,7 +329,7 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
323 if (ret < 0) 329 if (ret < 0)
324 log("Unable to set up audio system (ret=%d)\n", ret); 330 log("Unable to set up audio system (ret=%d)\n", ret);
325 } 331 }
326 332
327 if (dev->spec.num_midi_in + 333 if (dev->spec.num_midi_in +
328 dev->spec.num_midi_out > 0) { 334 dev->spec.num_midi_out > 0) {
329 ret = snd_usb_caiaq_midi_init(dev); 335 ret = snd_usb_caiaq_midi_init(dev);
@@ -349,7 +355,9 @@ static void __devinit setup_card(struct snd_usb_caiaqdev *dev)
349 log("Unable to set up control system (ret=%d)\n", ret); 355 log("Unable to set up control system (ret=%d)\n", ret);
350} 356}
351 357
352static int create_card(struct usb_device* usb_dev, struct snd_card **cardp) 358static int create_card(struct usb_device *usb_dev,
359 struct usb_interface *intf,
360 struct snd_card **cardp)
353{ 361{
354 int devnum; 362 int devnum;
355 int err; 363 int err;
@@ -363,7 +371,7 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
363 if (devnum >= SNDRV_CARDS) 371 if (devnum >= SNDRV_CARDS)
364 return -ENODEV; 372 return -ENODEV;
365 373
366 err = snd_card_create(index[devnum], id[devnum], THIS_MODULE, 374 err = snd_card_create(index[devnum], id[devnum], THIS_MODULE,
367 sizeof(struct snd_usb_caiaqdev), &card); 375 sizeof(struct snd_usb_caiaqdev), &card);
368 if (err < 0) 376 if (err < 0)
369 return err; 377 return err;
@@ -374,7 +382,7 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
374 dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), 382 dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor),
375 le16_to_cpu(usb_dev->descriptor.idProduct)); 383 le16_to_cpu(usb_dev->descriptor.idProduct));
376 spin_lock_init(&dev->spinlock); 384 spin_lock_init(&dev->spinlock);
377 snd_card_set_dev(card, &usb_dev->dev); 385 snd_card_set_dev(card, &intf->dev);
378 386
379 *cardp = card; 387 *cardp = card;
380 return 0; 388 return 0;
@@ -382,11 +390,11 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
382 390
383static int __devinit init_card(struct snd_usb_caiaqdev *dev) 391static int __devinit init_card(struct snd_usb_caiaqdev *dev)
384{ 392{
385 char *c; 393 char *c, usbpath[32];
386 struct usb_device *usb_dev = dev->chip.dev; 394 struct usb_device *usb_dev = dev->chip.dev;
387 struct snd_card *card = dev->chip.card; 395 struct snd_card *card = dev->chip.card;
388 int err, len; 396 int err, len;
389 397
390 if (usb_set_interface(usb_dev, 0, 1) != 0) { 398 if (usb_set_interface(usb_dev, 0, 1) != 0) {
391 log("can't set alt interface.\n"); 399 log("can't set alt interface.\n");
392 return -EIO; 400 return -EIO;
@@ -395,19 +403,19 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)
395 usb_init_urb(&dev->ep1_in_urb); 403 usb_init_urb(&dev->ep1_in_urb);
396 usb_init_urb(&dev->midi_out_urb); 404 usb_init_urb(&dev->midi_out_urb);
397 405
398 usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, 406 usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev,
399 usb_rcvbulkpipe(usb_dev, 0x1), 407 usb_rcvbulkpipe(usb_dev, 0x1),
400 dev->ep1_in_buf, EP1_BUFSIZE, 408 dev->ep1_in_buf, EP1_BUFSIZE,
401 usb_ep1_command_reply_dispatch, dev); 409 usb_ep1_command_reply_dispatch, dev);
402 410
403 usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, 411 usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev,
404 usb_sndbulkpipe(usb_dev, 0x1), 412 usb_sndbulkpipe(usb_dev, 0x1),
405 dev->midi_out_buf, EP1_BUFSIZE, 413 dev->midi_out_buf, EP1_BUFSIZE,
406 snd_usb_caiaq_midi_output_done, dev); 414 snd_usb_caiaq_midi_output_done, dev);
407 415
408 init_waitqueue_head(&dev->ep1_wait_queue); 416 init_waitqueue_head(&dev->ep1_wait_queue);
409 init_waitqueue_head(&dev->prepare_wait_queue); 417 init_waitqueue_head(&dev->prepare_wait_queue);
410 418
411 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) 419 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0)
412 return -EIO; 420 return -EIO;
413 421
@@ -420,47 +428,52 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)
420 428
421 usb_string(usb_dev, usb_dev->descriptor.iManufacturer, 429 usb_string(usb_dev, usb_dev->descriptor.iManufacturer,
422 dev->vendor_name, CAIAQ_USB_STR_LEN); 430 dev->vendor_name, CAIAQ_USB_STR_LEN);
423 431
424 usb_string(usb_dev, usb_dev->descriptor.iProduct, 432 usb_string(usb_dev, usb_dev->descriptor.iProduct,
425 dev->product_name, CAIAQ_USB_STR_LEN); 433 dev->product_name, CAIAQ_USB_STR_LEN);
426 434
427 usb_string(usb_dev, usb_dev->descriptor.iSerialNumber, 435 strlcpy(card->driver, MODNAME, sizeof(card->driver));
428 dev->serial, CAIAQ_USB_STR_LEN); 436 strlcpy(card->shortname, dev->product_name, sizeof(card->shortname));
429 437 strlcpy(card->mixername, dev->product_name, sizeof(card->mixername));
430 /* terminate serial string at first white space occurence */ 438
431 c = strchr(dev->serial, ' '); 439 /* if the id was not passed as module option, fill it with a shortened
432 if (c) 440 * version of the product string which does not contain any
433 *c = '\0'; 441 * whitespaces */
434 442
435 strcpy(card->driver, MODNAME); 443 if (*card->id == '\0') {
436 strcpy(card->shortname, dev->product_name); 444 char id[sizeof(card->id)];
437 445
438 len = snprintf(card->longname, sizeof(card->longname), 446 memset(id, 0, sizeof(id));
439 "%s %s (serial %s, ", 447
440 dev->vendor_name, dev->product_name, dev->serial); 448 for (c = card->shortname, len = 0;
441 449 *c && len < sizeof(card->id); c++)
442 if (len < sizeof(card->longname) - 2) 450 if (*c != ' ')
443 len += usb_make_path(usb_dev, card->longname + len, 451 id[len++] = *c;
444 sizeof(card->longname) - len); 452
445 453 snd_card_set_id(card, id);
446 card->longname[len++] = ')'; 454 }
447 card->longname[len] = '\0'; 455
456 usb_make_path(usb_dev, usbpath, sizeof(usbpath));
457 snprintf(card->longname, sizeof(card->longname),
458 "%s %s (%s)",
459 dev->vendor_name, dev->product_name, usbpath);
460
448 setup_card(dev); 461 setup_card(dev);
449 return 0; 462 return 0;
450} 463}
451 464
452static int __devinit snd_probe(struct usb_interface *intf, 465static int __devinit snd_probe(struct usb_interface *intf,
453 const struct usb_device_id *id) 466 const struct usb_device_id *id)
454{ 467{
455 int ret; 468 int ret;
456 struct snd_card *card; 469 struct snd_card *card;
457 struct usb_device *device = interface_to_usbdev(intf); 470 struct usb_device *device = interface_to_usbdev(intf);
458 471
459 ret = create_card(device, &card); 472 ret = create_card(device, intf, &card);
460 473
461 if (ret < 0) 474 if (ret < 0)
462 return ret; 475 return ret;
463 476
464 usb_set_intfdata(intf, card); 477 usb_set_intfdata(intf, card);
465 ret = init_card(caiaqdev(card)); 478 ret = init_card(caiaqdev(card));
466 if (ret < 0) { 479 if (ret < 0) {
@@ -468,7 +481,7 @@ static int __devinit snd_probe(struct usb_interface *intf,
468 snd_card_free(card); 481 snd_card_free(card);
469 return ret; 482 return ret;
470 } 483 }
471 484
472 return 0; 485 return 0;
473} 486}
474 487
@@ -489,10 +502,10 @@ static void snd_disconnect(struct usb_interface *intf)
489 snd_usb_caiaq_input_free(dev); 502 snd_usb_caiaq_input_free(dev);
490#endif 503#endif
491 snd_usb_caiaq_audio_free(dev); 504 snd_usb_caiaq_audio_free(dev);
492 505
493 usb_kill_urb(&dev->ep1_in_urb); 506 usb_kill_urb(&dev->ep1_in_urb);
494 usb_kill_urb(&dev->midi_out_urb); 507 usb_kill_urb(&dev->midi_out_urb);
495 508
496 snd_card_free(card); 509 snd_card_free(card);
497 usb_reset_device(interface_to_usbdev(intf)); 510 usb_reset_device(interface_to_usbdev(intf));
498} 511}
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h
index 4cce1ad7493d..44e3edf88bef 100644
--- a/sound/usb/caiaq/device.h
+++ b/sound/usb/caiaq/device.h
@@ -10,6 +10,7 @@
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_AUDIO2DJ 0x041c
13#define USB_PID_AUDIO4DJ 0x0839 14#define USB_PID_AUDIO4DJ 0x0839
14#define USB_PID_AUDIO8DJ 0x1978 15#define USB_PID_AUDIO8DJ 0x1978
15#define USB_PID_SESSIONIO 0x1915 16#define USB_PID_SESSIONIO 0x1915
@@ -81,7 +82,6 @@ struct snd_usb_caiaqdev {
81 82
82 char vendor_name[CAIAQ_USB_STR_LEN]; 83 char vendor_name[CAIAQ_USB_STR_LEN];
83 char product_name[CAIAQ_USB_STR_LEN]; 84 char product_name[CAIAQ_USB_STR_LEN];
84 char serial[CAIAQ_USB_STR_LEN];
85 85
86 int n_streams, n_audio_in, n_audio_out; 86 int n_streams, n_audio_in, n_audio_out;
87 int streaming, first_packet, output_running; 87 int streaming, first_packet, output_running;
diff --git a/sound/usb/caiaq/midi.c b/sound/usb/caiaq/midi.c
index 8fa8cd88d763..538e8c00d31a 100644
--- a/sound/usb/caiaq/midi.c
+++ b/sound/usb/caiaq/midi.c
@@ -40,7 +40,7 @@ static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *subst
40 40
41 if (!dev) 41 if (!dev)
42 return; 42 return;
43 43
44 dev->midi_receive_substream = up ? substream : NULL; 44 dev->midi_receive_substream = up ? substream : NULL;
45} 45}
46 46
@@ -64,18 +64,18 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
64 struct snd_rawmidi_substream *substream) 64 struct snd_rawmidi_substream *substream)
65{ 65{
66 int len, ret; 66 int len, ret;
67 67
68 dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; 68 dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
69 dev->midi_out_buf[1] = 0; /* port */ 69 dev->midi_out_buf[1] = 0; /* port */
70 len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3, 70 len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
71 EP1_BUFSIZE - 3); 71 EP1_BUFSIZE - 3);
72 72
73 if (len <= 0) 73 if (len <= 0)
74 return; 74 return;
75 75
76 dev->midi_out_buf[2] = len; 76 dev->midi_out_buf[2] = len;
77 dev->midi_out_urb.transfer_buffer_length = len+3; 77 dev->midi_out_urb.transfer_buffer_length = len+3;
78 78
79 ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC); 79 ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
80 if (ret < 0) 80 if (ret < 0)
81 log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," 81 log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
@@ -88,7 +88,7 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
88static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) 88static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
89{ 89{
90 struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; 90 struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
91 91
92 if (up) { 92 if (up) {
93 dev->midi_out_substream = substream; 93 dev->midi_out_substream = substream;
94 if (!dev->midi_out_active) 94 if (!dev->midi_out_active)
@@ -113,12 +113,12 @@ static struct snd_rawmidi_ops snd_usb_caiaq_midi_input =
113 .trigger = snd_usb_caiaq_midi_input_trigger, 113 .trigger = snd_usb_caiaq_midi_input_trigger,
114}; 114};
115 115
116void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, 116void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev,
117 int port, const char *buf, int len) 117 int port, const char *buf, int len)
118{ 118{
119 if (!dev->midi_receive_substream) 119 if (!dev->midi_receive_substream)
120 return; 120 return;
121 121
122 snd_rawmidi_receive(dev->midi_receive_substream, buf, len); 122 snd_rawmidi_receive(dev->midi_receive_substream, buf, len);
123} 123}
124 124
@@ -142,16 +142,16 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
142 142
143 if (device->spec.num_midi_out > 0) { 143 if (device->spec.num_midi_out > 0) {
144 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; 144 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT;
145 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, 145 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
146 &snd_usb_caiaq_midi_output); 146 &snd_usb_caiaq_midi_output);
147 } 147 }
148 148
149 if (device->spec.num_midi_in > 0) { 149 if (device->spec.num_midi_in > 0) {
150 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; 150 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT;
151 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, 151 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
152 &snd_usb_caiaq_midi_input); 152 &snd_usb_caiaq_midi_input);
153 } 153 }
154 154
155 device->rmidi = rmidi; 155 device->rmidi = rmidi;
156 156
157 return 0; 157 return 0;
@@ -160,7 +160,7 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
160void snd_usb_caiaq_midi_output_done(struct urb* urb) 160void snd_usb_caiaq_midi_output_done(struct urb* urb)
161{ 161{
162 struct snd_usb_caiaqdev *dev = urb->context; 162 struct snd_usb_caiaqdev *dev = urb->context;
163 163
164 dev->midi_out_active = 0; 164 dev->midi_out_active = 0;
165 if (urb->status != 0) 165 if (urb->status != 0)
166 return; 166 return;
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index a6b88482637b..3a53c79f48b8 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -627,6 +627,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,
627 subs->hwptr_done += offs; 627 subs->hwptr_done += offs;
628 if (subs->hwptr_done >= runtime->buffer_size) 628 if (subs->hwptr_done >= runtime->buffer_size)
629 subs->hwptr_done -= runtime->buffer_size; 629 subs->hwptr_done -= runtime->buffer_size;
630 runtime->delay += offs;
630 spin_unlock_irqrestore(&subs->lock, flags); 631 spin_unlock_irqrestore(&subs->lock, flags);
631 urb->transfer_buffer_length = offs * stride; 632 urb->transfer_buffer_length = offs * stride;
632 if (period_elapsed) 633 if (period_elapsed)
@@ -636,12 +637,22 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,
636 637
637/* 638/*
638 * process after playback data complete 639 * process after playback data complete
639 * - nothing to do 640 * - decrease the delay count again
640 */ 641 */
641static int retire_playback_urb(struct snd_usb_substream *subs, 642static int retire_playback_urb(struct snd_usb_substream *subs,
642 struct snd_pcm_runtime *runtime, 643 struct snd_pcm_runtime *runtime,
643 struct urb *urb) 644 struct urb *urb)
644{ 645{
646 unsigned long flags;
647 int stride = runtime->frame_bits >> 3;
648 int processed = urb->transfer_buffer_length / stride;
649
650 spin_lock_irqsave(&subs->lock, flags);
651 if (processed > runtime->delay)
652 runtime->delay = 0;
653 else
654 runtime->delay -= processed;
655 spin_unlock_irqrestore(&subs->lock, flags);
645 return 0; 656 return 0;
646} 657}
647 658
@@ -1520,6 +1531,7 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
1520 subs->hwptr_done = 0; 1531 subs->hwptr_done = 0;
1521 subs->transfer_done = 0; 1532 subs->transfer_done = 0;
1522 subs->phase = 0; 1533 subs->phase = 0;
1534 runtime->delay = 0;
1523 1535
1524 /* clear urbs (to be sure) */ 1536 /* clear urbs (to be sure) */
1525 deactivate_urbs(subs, 0, 1); 1537 deactivate_urbs(subs, 0, 1);
@@ -2112,8 +2124,8 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2112 fp = list_entry(p, struct audioformat, list); 2124 fp = list_entry(p, struct audioformat, list);
2113 snd_iprintf(buffer, " Interface %d\n", fp->iface); 2125 snd_iprintf(buffer, " Interface %d\n", fp->iface);
2114 snd_iprintf(buffer, " Altset %d\n", fp->altsetting); 2126 snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
2115 snd_iprintf(buffer, " Format: %#x (%d bits)\n", 2127 snd_iprintf(buffer, " Format: %s\n",
2116 fp->format, snd_pcm_format_width(fp->format)); 2128 snd_pcm_format_name(fp->format));
2117 snd_iprintf(buffer, " Channels: %d\n", fp->channels); 2129 snd_iprintf(buffer, " Channels: %d\n", fp->channels);
2118 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", 2130 snd_iprintf(buffer, " Endpoint: %d %s (%s)\n",
2119 fp->endpoint & USB_ENDPOINT_NUMBER_MASK, 2131 fp->endpoint & USB_ENDPOINT_NUMBER_MASK,
@@ -2649,7 +2661,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2649 struct usb_interface_descriptor *altsd; 2661 struct usb_interface_descriptor *altsd;
2650 int i, altno, err, stream; 2662 int i, altno, err, stream;
2651 int format; 2663 int format;
2652 struct audioformat *fp; 2664 struct audioformat *fp = NULL;
2653 unsigned char *fmt, *csep; 2665 unsigned char *fmt, *csep;
2654 int num; 2666 int num;
2655 2667
@@ -2722,6 +2734,18 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2722 continue; 2734 continue;
2723 } 2735 }
2724 2736
2737 /*
2738 * Blue Microphones workaround: The last altsetting is identical
2739 * with the previous one, except for a larger packet size, but
2740 * is actually a mislabeled two-channel setting; ignore it.
2741 */
2742 if (fmt[4] == 1 && fmt[5] == 2 && altno == 2 && num == 3 &&
2743 fp && fp->altsetting == 1 && fp->channels == 1 &&
2744 fp->format == SNDRV_PCM_FORMAT_S16_LE &&
2745 le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) ==
2746 fp->maxpacksize * 2)
2747 continue;
2748
2725 csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT); 2749 csep = snd_usb_find_desc(alts->endpoint[0].extra, alts->endpoint[0].extralen, NULL, USB_DT_CS_ENDPOINT);
2726 /* Creamware Noah has this descriptor after the 2nd endpoint */ 2750 /* Creamware Noah has this descriptor after the 2nd endpoint */
2727 if (!csep && altsd->bNumEndpoints >= 2) 2751 if (!csep && altsd->bNumEndpoints >= 2)
@@ -3279,6 +3303,25 @@ static int snd_usb_cm106_boot_quirk(struct usb_device *dev)
3279 return snd_usb_cm106_write_int_reg(dev, 2, 0x8004); 3303 return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
3280} 3304}
3281 3305
3306/*
3307 * C-Media CM6206 is based on CM106 with two additional
3308 * registers that are not documented in the data sheet.
3309 * Values here are chosen based on sniffing USB traffic
3310 * under Windows.
3311 */
3312static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)
3313{
3314 int err, reg;
3315 int val[] = {0x200c, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000};
3316
3317 for (reg = 0; reg < ARRAY_SIZE(val); reg++) {
3318 err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]);
3319 if (err < 0)
3320 return err;
3321 }
3322
3323 return err;
3324}
3282 3325
3283/* 3326/*
3284 * Setup quirks 3327 * Setup quirks
@@ -3565,6 +3608,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
3565 goto __err_val; 3608 goto __err_val;
3566 } 3609 }
3567 3610
3611 /* C-Media CM6206 / CM106-Like Sound Device */
3612 if (id == USB_ID(0x0d8c, 0x0102)) {
3613 if (snd_usb_cm6206_boot_quirk(dev) < 0)
3614 goto __err_val;
3615 }
3616
3568 /* 3617 /*
3569 * found a config. now register to ALSA 3618 * found a config. now register to ALSA
3570 */ 3619 */
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 539b427d08c6..df8969188d15 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -423,7 +423,7 @@ static int set_ctl_value(struct usb_mixer_elem_info *cval, int request, int vali
423 value_set = convert_bytes_value(cval, value_set); 423 value_set = convert_bytes_value(cval, value_set);
424 buf[0] = value_set & 0xff; 424 buf[0] = value_set & 0xff;
425 buf[1] = (value_set >> 8) & 0xff; 425 buf[1] = (value_set >> 8) & 0xff;
426 while (timeout -- > 0) 426 while (timeout-- > 0)
427 if (snd_usb_ctl_msg(cval->mixer->chip->dev, 427 if (snd_usb_ctl_msg(cval->mixer->chip->dev,
428 usb_sndctrlpipe(cval->mixer->chip->dev, 0), 428 usb_sndctrlpipe(cval->mixer->chip->dev, 0),
429 request, 429 request,
@@ -999,20 +999,35 @@ static void build_feature_ctl(struct mixer_build *state, unsigned char *desc,
999 break; 999 break;
1000 } 1000 }
1001 1001
1002 /* quirk for UDA1321/N101 */ 1002 /* volume control quirks */
1003 /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */
1004 /* is not very clear from datasheets */
1005 /* I hope that the min value is -15360 for newer firmware --jk */
1006 switch (state->chip->usb_id) { 1003 switch (state->chip->usb_id) {
1007 case USB_ID(0x0471, 0x0101): 1004 case USB_ID(0x0471, 0x0101):
1008 case USB_ID(0x0471, 0x0104): 1005 case USB_ID(0x0471, 0x0104):
1009 case USB_ID(0x0471, 0x0105): 1006 case USB_ID(0x0471, 0x0105):
1010 case USB_ID(0x0672, 0x1041): 1007 case USB_ID(0x0672, 0x1041):
1008 /* quirk for UDA1321/N101.
1009 * note that detection between firmware 2.1.1.7 (N101)
1010 * and later 2.1.1.21 is not very clear from datasheets.
1011 * I hope that the min value is -15360 for newer firmware --jk
1012 */
1011 if (!strcmp(kctl->id.name, "PCM Playback Volume") && 1013 if (!strcmp(kctl->id.name, "PCM Playback Volume") &&
1012 cval->min == -15616) { 1014 cval->min == -15616) {
1013 snd_printk(KERN_INFO "using volume control quirk for the UDA1321/N101 chip\n"); 1015 snd_printk(KERN_INFO
1016 "set volume quirk for UDA1321/N101 chip\n");
1014 cval->max = -256; 1017 cval->max = -256;
1015 } 1018 }
1019 break;
1020
1021 case USB_ID(0x046d, 0x09a4):
1022 if (!strcmp(kctl->id.name, "Mic Capture Volume")) {
1023 snd_printk(KERN_INFO
1024 "set volume quirk for QuickCam E3500\n");
1025 cval->min = 6080;
1026 cval->max = 8768;
1027 cval->res = 192;
1028 }
1029 break;
1030
1016 } 1031 }
1017 1032
1018 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", 1033 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 5d955aaad85f..f6f201eb24ce 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -1470,6 +1470,41 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1470 } 1470 }
1471}, 1471},
1472{ 1472{
1473 /* Edirol M-16DX */
1474 /* FIXME: This quirk gives a good-working capture stream but the
1475 * playback seems problematic because of lacking of sync
1476 * with capture stream. It needs to sync with the capture
1477 * clock. As now, you'll get frequent sound distortions
1478 * via the playback.
1479 */
1480 USB_DEVICE(0x0582, 0x00c4),
1481 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1482 .ifnum = QUIRK_ANY_INTERFACE,
1483 .type = QUIRK_COMPOSITE,
1484 .data = (const struct snd_usb_audio_quirk[]) {
1485 {
1486 .ifnum = 0,
1487 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1488 },
1489 {
1490 .ifnum = 1,
1491 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1492 },
1493 {
1494 .ifnum = 2,
1495 .type = QUIRK_MIDI_FIXED_ENDPOINT,
1496 .data = & (const struct snd_usb_midi_endpoint_info) {
1497 .out_cables = 0x0001,
1498 .in_cables = 0x0001
1499 }
1500 },
1501 {
1502 .ifnum = -1
1503 }
1504 }
1505 }
1506},
1507{
1473 /* BOSS GT-10 */ 1508 /* BOSS GT-10 */
1474 USB_DEVICE(0x0582, 0x00da), 1509 USB_DEVICE(0x0582, 0x00da),
1475 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 1510 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
@@ -1951,6 +1986,14 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1951 } 1986 }
1952}, 1987},
1953{ 1988{
1989 USB_DEVICE(0x0ccd, 0x0028),
1990 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1991 .vendor_name = "TerraTec",
1992 .product_name = "Aureon5.1MkII",
1993 .ifnum = QUIRK_NO_INTERFACE
1994 }
1995},
1996{
1954 USB_DEVICE(0x0ccd, 0x0035), 1997 USB_DEVICE(0x0ccd, 0x0035),
1955 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { 1998 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1956 .vendor_name = "Miditech", 1999 .vendor_name = "Miditech",
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index a5aae9d67f31..fd44946ce4b3 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -514,7 +514,6 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
514 US122L(card)->chip.dev->bus->busnum, 514 US122L(card)->chip.dev->bus->busnum,
515 US122L(card)->chip.dev->devnum 515 US122L(card)->chip.dev->devnum
516 ); 516 );
517 snd_card_set_dev(card, &device->dev);
518 *cardp = card; 517 *cardp = card;
519 return 0; 518 return 0;
520} 519}
@@ -531,6 +530,7 @@ static int us122l_usb_probe(struct usb_interface *intf,
531 if (err < 0) 530 if (err < 0)
532 return err; 531 return err;
533 532
533 snd_card_set_dev(card, &intf->dev);
534 if (!us122l_create_card(card)) { 534 if (!us122l_create_card(card)) {
535 snd_card_free(card); 535 snd_card_free(card);
536 return -EINVAL; 536 return -EINVAL;
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index 5ce0da23ee96..cb4bb8373ca2 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -364,7 +364,6 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
364 0,//us428(card)->usbmidi.ifnum, 364 0,//us428(card)->usbmidi.ifnum,
365 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum 365 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum
366 ); 366 );
367 snd_card_set_dev(card, &device->dev);
368 *cardp = card; 367 *cardp = card;
369 return 0; 368 return 0;
370} 369}
@@ -388,6 +387,7 @@ static int usX2Y_usb_probe(struct usb_device *device,
388 err = usX2Y_create_card(device, &card); 387 err = usX2Y_create_card(device, &card);
389 if (err < 0) 388 if (err < 0)
390 return err; 389 return err;
390 snd_card_set_dev(card, &intf->dev);
391 if ((err = usX2Y_hwdep_new(card, device)) < 0 || 391 if ((err = usX2Y_hwdep_new(card, device)) < 0 ||
392 (err = snd_card_register(card)) < 0) { 392 (err = snd_card_register(card)) < 0) {
393 snd_card_free(card); 393 snd_card_free(card);
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index dd1ab6177840..9efd27f6b52f 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -296,9 +296,10 @@ static void usX2Y_error_urb_status(struct usX2Ydev *usX2Y,
296static void usX2Y_error_sequence(struct usX2Ydev *usX2Y, 296static void usX2Y_error_sequence(struct usX2Ydev *usX2Y,
297 struct snd_usX2Y_substream *subs, struct urb *urb) 297 struct snd_usX2Y_substream *subs, struct urb *urb)
298{ 298{
299 snd_printk(KERN_ERR "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" 299 snd_printk(KERN_ERR
300 KERN_ERR "Most propably some urb of usb-frame %i is still missing.\n" 300"Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n"
301 KERN_ERR "Cause could be too long delays in usb-hcd interrupt handling.\n", 301"Most propably some urb of usb-frame %i is still missing.\n"
302"Cause could be too long delays in usb-hcd interrupt handling.\n",
302 usb_get_current_frame_number(usX2Y->chip.dev), 303 usb_get_current_frame_number(usX2Y->chip.dev),
303 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", 304 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out",
304 usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); 305 usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame);