aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usx2y/us122l.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/usx2y/us122l.c')
-rw-r--r--sound/usb/usx2y/us122l.c151
1 files changed, 112 insertions, 39 deletions
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 99f33766cd51..91bb29666d26 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -59,11 +59,33 @@ static int us122l_create_usbmidi(struct snd_card *card)
59 .type = QUIRK_MIDI_US122L, 59 .type = QUIRK_MIDI_US122L,
60 .data = &quirk_data 60 .data = &quirk_data
61 }; 61 };
62 struct usb_device *dev = US122L(card)->chip.dev; 62 struct usb_device *dev = US122L(card)->dev;
63 struct usb_interface *iface = usb_ifnum_to_if(dev, 1); 63 struct usb_interface *iface = usb_ifnum_to_if(dev, 1);
64 64
65 return snd_usb_create_midi_interface(&US122L(card)->chip, 65 return snd_usbmidi_create(card, iface,
66 iface, &quirk); 66 &US122L(card)->midi_list, &quirk);
67}
68
69static int us144_create_usbmidi(struct snd_card *card)
70{
71 static struct snd_usb_midi_endpoint_info quirk_data = {
72 .out_ep = 4,
73 .in_ep = 3,
74 .out_cables = 0x001,
75 .in_cables = 0x001
76 };
77 static struct snd_usb_audio_quirk quirk = {
78 .vendor_name = "US144",
79 .product_name = NAME_ALLCAPS,
80 .ifnum = 0,
81 .type = QUIRK_MIDI_US122L,
82 .data = &quirk_data
83 };
84 struct usb_device *dev = US122L(card)->dev;
85 struct usb_interface *iface = usb_ifnum_to_if(dev, 0);
86
87 return snd_usbmidi_create(card, iface,
88 &US122L(card)->midi_list, &quirk);
67} 89}
68 90
69/* 91/*
@@ -171,7 +193,13 @@ static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file)
171 193
172 if (!us122l->first) 194 if (!us122l->first)
173 us122l->first = file; 195 us122l->first = file;
174 iface = usb_ifnum_to_if(us122l->chip.dev, 1); 196
197 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
198 us122l->dev->descriptor.idProduct == USB_ID_US144MKII) {
199 iface = usb_ifnum_to_if(us122l->dev, 0);
200 usb_autopm_get_interface(iface);
201 }
202 iface = usb_ifnum_to_if(us122l->dev, 1);
175 usb_autopm_get_interface(iface); 203 usb_autopm_get_interface(iface);
176 return 0; 204 return 0;
177} 205}
@@ -179,8 +207,15 @@ static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file)
179static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file) 207static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file)
180{ 208{
181 struct us122l *us122l = hw->private_data; 209 struct us122l *us122l = hw->private_data;
182 struct usb_interface *iface = usb_ifnum_to_if(us122l->chip.dev, 1); 210 struct usb_interface *iface;
183 snd_printdd(KERN_DEBUG "%p %p\n", hw, file); 211 snd_printdd(KERN_DEBUG "%p %p\n", hw, file);
212
213 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
214 us122l->dev->descriptor.idProduct == USB_ID_US144MKII) {
215 iface = usb_ifnum_to_if(us122l->dev, 0);
216 usb_autopm_put_interface(iface);
217 }
218 iface = usb_ifnum_to_if(us122l->dev, 1);
184 usb_autopm_put_interface(iface); 219 usb_autopm_put_interface(iface);
185 if (us122l->first == file) 220 if (us122l->first == file)
186 us122l->first = NULL; 221 us122l->first = NULL;
@@ -264,7 +299,7 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw,
264static void us122l_stop(struct us122l *us122l) 299static void us122l_stop(struct us122l *us122l)
265{ 300{
266 struct list_head *p; 301 struct list_head *p;
267 list_for_each(p, &us122l->chip.midi_list) 302 list_for_each(p, &us122l->midi_list)
268 snd_usbmidi_input_stop(p); 303 snd_usbmidi_input_stop(p);
269 304
270 usb_stream_stop(&us122l->sk); 305 usb_stream_stop(&us122l->sk);
@@ -297,7 +332,7 @@ static bool us122l_start(struct us122l *us122l,
297 unsigned use_packsize = 0; 332 unsigned use_packsize = 0;
298 bool success = false; 333 bool success = false;
299 334
300 if (us122l->chip.dev->speed == USB_SPEED_HIGH) { 335 if (us122l->dev->speed == USB_SPEED_HIGH) {
301 /* The us-122l's descriptor defaults to iso max_packsize 78, 336 /* The us-122l's descriptor defaults to iso max_packsize 78,
302 which isn't needed for samplerates <= 48000. 337 which isn't needed for samplerates <= 48000.
303 Lets save some memory: 338 Lets save some memory:
@@ -314,11 +349,11 @@ static bool us122l_start(struct us122l *us122l,
314 break; 349 break;
315 } 350 }
316 } 351 }
317 if (!usb_stream_new(&us122l->sk, us122l->chip.dev, 1, 2, 352 if (!usb_stream_new(&us122l->sk, us122l->dev, 1, 2,
318 rate, use_packsize, period_frames, 6)) 353 rate, use_packsize, period_frames, 6))
319 goto out; 354 goto out;
320 355
321 err = us122l_set_sample_rate(us122l->chip.dev, rate); 356 err = us122l_set_sample_rate(us122l->dev, rate);
322 if (err < 0) { 357 if (err < 0) {
323 us122l_stop(us122l); 358 us122l_stop(us122l);
324 snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); 359 snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
@@ -330,7 +365,7 @@ static bool us122l_start(struct us122l *us122l,
330 snd_printk(KERN_ERR "us122l_start error %i \n", err); 365 snd_printk(KERN_ERR "us122l_start error %i \n", err);
331 goto out; 366 goto out;
332 } 367 }
333 list_for_each(p, &us122l->chip.midi_list) 368 list_for_each(p, &us122l->midi_list)
334 snd_usbmidi_input_start(p); 369 snd_usbmidi_input_start(p);
335 success = true; 370 success = true;
336out: 371out:
@@ -357,7 +392,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
357 err = -ENXIO; 392 err = -ENXIO;
358 goto free; 393 goto free;
359 } 394 }
360 high_speed = us122l->chip.dev->speed == USB_SPEED_HIGH; 395 high_speed = us122l->dev->speed == USB_SPEED_HIGH;
361 if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 && 396 if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 &&
362 (!high_speed || 397 (!high_speed ||
363 (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) || 398 (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) ||
@@ -417,7 +452,7 @@ static int usb_stream_hwdep_new(struct snd_card *card)
417{ 452{
418 int err; 453 int err;
419 struct snd_hwdep *hw; 454 struct snd_hwdep *hw;
420 struct usb_device *dev = US122L(card)->chip.dev; 455 struct usb_device *dev = US122L(card)->dev;
421 456
422 err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw); 457 err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw);
423 if (err < 0) 458 if (err < 0)
@@ -443,19 +478,31 @@ static bool us122l_create_card(struct snd_card *card)
443 int err; 478 int err;
444 struct us122l *us122l = US122L(card); 479 struct us122l *us122l = US122L(card);
445 480
446 err = usb_set_interface(us122l->chip.dev, 1, 1); 481 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
482 us122l->dev->descriptor.idProduct == USB_ID_US144MKII) {
483 err = usb_set_interface(us122l->dev, 0, 1);
484 if (err) {
485 snd_printk(KERN_ERR "usb_set_interface error \n");
486 return false;
487 }
488 }
489 err = usb_set_interface(us122l->dev, 1, 1);
447 if (err) { 490 if (err) {
448 snd_printk(KERN_ERR "usb_set_interface error \n"); 491 snd_printk(KERN_ERR "usb_set_interface error \n");
449 return false; 492 return false;
450 } 493 }
451 494
452 pt_info_set(us122l->chip.dev, 0x11); 495 pt_info_set(us122l->dev, 0x11);
453 pt_info_set(us122l->chip.dev, 0x10); 496 pt_info_set(us122l->dev, 0x10);
454 497
455 if (!us122l_start(us122l, 44100, 256)) 498 if (!us122l_start(us122l, 44100, 256))
456 return false; 499 return false;
457 500
458 err = us122l_create_usbmidi(card); 501 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
502 us122l->dev->descriptor.idProduct == USB_ID_US144MKII)
503 err = us144_create_usbmidi(card);
504 else
505 err = us122l_create_usbmidi(card);
459 if (err < 0) { 506 if (err < 0) {
460 snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err); 507 snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err);
461 us122l_stop(us122l); 508 us122l_stop(us122l);
@@ -465,7 +512,7 @@ static bool us122l_create_card(struct snd_card *card)
465 if (err < 0) { 512 if (err < 0) {
466/* release the midi resources */ 513/* release the midi resources */
467 struct list_head *p; 514 struct list_head *p;
468 list_for_each(p, &us122l->chip.midi_list) 515 list_for_each(p, &us122l->midi_list)
469 snd_usbmidi_disconnect(p); 516 snd_usbmidi_disconnect(p);
470 517
471 us122l_stop(us122l); 518 us122l_stop(us122l);
@@ -477,7 +524,7 @@ static bool us122l_create_card(struct snd_card *card)
477static void snd_us122l_free(struct snd_card *card) 524static void snd_us122l_free(struct snd_card *card)
478{ 525{
479 struct us122l *us122l = US122L(card); 526 struct us122l *us122l = US122L(card);
480 int index = us122l->chip.index; 527 int index = us122l->card_index;
481 if (index >= 0 && index < SNDRV_CARDS) 528 if (index >= 0 && index < SNDRV_CARDS)
482 snd_us122l_card_used[index] = 0; 529 snd_us122l_card_used[index] = 0;
483} 530}
@@ -497,13 +544,12 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
497 sizeof(struct us122l), &card); 544 sizeof(struct us122l), &card);
498 if (err < 0) 545 if (err < 0)
499 return err; 546 return err;
500 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 547 snd_us122l_card_used[US122L(card)->card_index = dev] = 1;
501 card->private_free = snd_us122l_free; 548 card->private_free = snd_us122l_free;
502 US122L(card)->chip.dev = device; 549 US122L(card)->dev = device;
503 US122L(card)->chip.card = card;
504 mutex_init(&US122L(card)->mutex); 550 mutex_init(&US122L(card)->mutex);
505 init_waitqueue_head(&US122L(card)->sk.sleep); 551 init_waitqueue_head(&US122L(card)->sk.sleep);
506 INIT_LIST_HEAD(&US122L(card)->chip.midi_list); 552 INIT_LIST_HEAD(&US122L(card)->midi_list);
507 strcpy(card->driver, "USB "NAME_ALLCAPS""); 553 strcpy(card->driver, "USB "NAME_ALLCAPS"");
508 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); 554 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
509 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", 555 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)",
@@ -511,8 +557,8 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
511 le16_to_cpu(device->descriptor.idVendor), 557 le16_to_cpu(device->descriptor.idVendor),
512 le16_to_cpu(device->descriptor.idProduct), 558 le16_to_cpu(device->descriptor.idProduct),
513 0, 559 0,
514 US122L(card)->chip.dev->bus->busnum, 560 US122L(card)->dev->bus->busnum,
515 US122L(card)->chip.dev->devnum 561 US122L(card)->dev->devnum
516 ); 562 );
517 *cardp = card; 563 *cardp = card;
518 return 0; 564 return 0;
@@ -542,6 +588,7 @@ static int us122l_usb_probe(struct usb_interface *intf,
542 return err; 588 return err;
543 } 589 }
544 590
591 usb_get_intf(usb_ifnum_to_if(device, 0));
545 usb_get_dev(device); 592 usb_get_dev(device);
546 *cardp = card; 593 *cardp = card;
547 return 0; 594 return 0;
@@ -550,9 +597,17 @@ static int us122l_usb_probe(struct usb_interface *intf,
550static int snd_us122l_probe(struct usb_interface *intf, 597static int snd_us122l_probe(struct usb_interface *intf,
551 const struct usb_device_id *id) 598 const struct usb_device_id *id)
552{ 599{
600 struct usb_device *device = interface_to_usbdev(intf);
553 struct snd_card *card; 601 struct snd_card *card;
554 int err; 602 int err;
555 603
604 if ((device->descriptor.idProduct == USB_ID_US144 ||
605 device->descriptor.idProduct == USB_ID_US144MKII)
606 && device->speed == USB_SPEED_HIGH) {
607 snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n");
608 return -ENODEV;
609 }
610
556 snd_printdd(KERN_DEBUG"%p:%i\n", 611 snd_printdd(KERN_DEBUG"%p:%i\n",
557 intf, intf->cur_altsetting->desc.bInterfaceNumber); 612 intf, intf->cur_altsetting->desc.bInterfaceNumber);
558 if (intf->cur_altsetting->desc.bInterfaceNumber != 1) 613 if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
@@ -584,15 +639,15 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
584 mutex_lock(&us122l->mutex); 639 mutex_lock(&us122l->mutex);
585 us122l_stop(us122l); 640 us122l_stop(us122l);
586 mutex_unlock(&us122l->mutex); 641 mutex_unlock(&us122l->mutex);
587 us122l->chip.shutdown = 1;
588 642
589/* release the midi resources */ 643/* release the midi resources */
590 list_for_each(p, &us122l->chip.midi_list) { 644 list_for_each(p, &us122l->midi_list) {
591 snd_usbmidi_disconnect(p); 645 snd_usbmidi_disconnect(p);
592 } 646 }
593 647
594 usb_put_intf(intf); 648 usb_put_intf(usb_ifnum_to_if(us122l->dev, 0));
595 usb_put_dev(us122l->chip.dev); 649 usb_put_intf(usb_ifnum_to_if(us122l->dev, 1));
650 usb_put_dev(us122l->dev);
596 651
597 while (atomic_read(&us122l->mmap_count)) 652 while (atomic_read(&us122l->mmap_count))
598 msleep(500); 653 msleep(500);
@@ -615,7 +670,7 @@ static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message)
615 if (!us122l) 670 if (!us122l)
616 return 0; 671 return 0;
617 672
618 list_for_each(p, &us122l->chip.midi_list) 673 list_for_each(p, &us122l->midi_list)
619 snd_usbmidi_input_stop(p); 674 snd_usbmidi_input_stop(p);
620 675
621 mutex_lock(&us122l->mutex); 676 mutex_lock(&us122l->mutex);
@@ -642,16 +697,24 @@ static int snd_us122l_resume(struct usb_interface *intf)
642 697
643 mutex_lock(&us122l->mutex); 698 mutex_lock(&us122l->mutex);
644 /* needed, doesn't restart without: */ 699 /* needed, doesn't restart without: */
645 err = usb_set_interface(us122l->chip.dev, 1, 1); 700 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
701 us122l->dev->descriptor.idProduct == USB_ID_US144MKII) {
702 err = usb_set_interface(us122l->dev, 0, 1);
703 if (err) {
704 snd_printk(KERN_ERR "usb_set_interface error \n");
705 goto unlock;
706 }
707 }
708 err = usb_set_interface(us122l->dev, 1, 1);
646 if (err) { 709 if (err) {
647 snd_printk(KERN_ERR "usb_set_interface error \n"); 710 snd_printk(KERN_ERR "usb_set_interface error \n");
648 goto unlock; 711 goto unlock;
649 } 712 }
650 713
651 pt_info_set(us122l->chip.dev, 0x11); 714 pt_info_set(us122l->dev, 0x11);
652 pt_info_set(us122l->chip.dev, 0x10); 715 pt_info_set(us122l->dev, 0x10);
653 716
654 err = us122l_set_sample_rate(us122l->chip.dev, 717 err = us122l_set_sample_rate(us122l->dev,
655 us122l->sk.s->cfg.sample_rate); 718 us122l->sk.s->cfg.sample_rate);
656 if (err < 0) { 719 if (err < 0) {
657 snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); 720 snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
@@ -661,7 +724,7 @@ static int snd_us122l_resume(struct usb_interface *intf)
661 if (err) 724 if (err)
662 goto unlock; 725 goto unlock;
663 726
664 list_for_each(p, &us122l->chip.midi_list) 727 list_for_each(p, &us122l->midi_list)
665 snd_usbmidi_input_start(p); 728 snd_usbmidi_input_start(p);
666unlock: 729unlock:
667 mutex_unlock(&us122l->mutex); 730 mutex_unlock(&us122l->mutex);
@@ -675,11 +738,21 @@ static struct usb_device_id snd_us122l_usb_id_table[] = {
675 .idVendor = 0x0644, 738 .idVendor = 0x0644,
676 .idProduct = USB_ID_US122L 739 .idProduct = USB_ID_US122L
677 }, 740 },
678/* { */ /* US-144 maybe works when @USB1.1. Untested. */ 741 { /* US-144 only works at USB1.1! Disable module ehci-hcd. */
679/* .match_flags = USB_DEVICE_ID_MATCH_DEVICE, */ 742 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
680/* .idVendor = 0x0644, */ 743 .idVendor = 0x0644,
681/* .idProduct = USB_ID_US144 */ 744 .idProduct = USB_ID_US144
682/* }, */ 745 },
746 {
747 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
748 .idVendor = 0x0644,
749 .idProduct = USB_ID_US122MKII
750 },
751 {
752 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
753 .idVendor = 0x0644,
754 .idProduct = USB_ID_US144MKII
755 },
683 { /* terminator */ } 756 { /* terminator */ }
684}; 757};
685 758