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.c108
1 files changed, 61 insertions, 47 deletions
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 00cd54c236b4..91bb29666d26 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -59,11 +59,11 @@ 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} 67}
68 68
69static int us144_create_usbmidi(struct snd_card *card) 69static int us144_create_usbmidi(struct snd_card *card)
@@ -81,11 +81,11 @@ static int us144_create_usbmidi(struct snd_card *card)
81 .type = QUIRK_MIDI_US122L, 81 .type = QUIRK_MIDI_US122L,
82 .data = &quirk_data 82 .data = &quirk_data
83 }; 83 };
84 struct usb_device *dev = US122L(card)->chip.dev; 84 struct usb_device *dev = US122L(card)->dev;
85 struct usb_interface *iface = usb_ifnum_to_if(dev, 0); 85 struct usb_interface *iface = usb_ifnum_to_if(dev, 0);
86 86
87 return snd_usb_create_midi_interface(&US122L(card)->chip, 87 return snd_usbmidi_create(card, iface,
88 iface, &quirk); 88 &US122L(card)->midi_list, &quirk);
89} 89}
90 90
91/* 91/*
@@ -194,11 +194,12 @@ static int usb_stream_hwdep_open(struct snd_hwdep *hw, struct file *file)
194 if (!us122l->first) 194 if (!us122l->first)
195 us122l->first = file; 195 us122l->first = file;
196 196
197 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) { 197 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
198 iface = usb_ifnum_to_if(us122l->chip.dev, 0); 198 us122l->dev->descriptor.idProduct == USB_ID_US144MKII) {
199 iface = usb_ifnum_to_if(us122l->dev, 0);
199 usb_autopm_get_interface(iface); 200 usb_autopm_get_interface(iface);
200 } 201 }
201 iface = usb_ifnum_to_if(us122l->chip.dev, 1); 202 iface = usb_ifnum_to_if(us122l->dev, 1);
202 usb_autopm_get_interface(iface); 203 usb_autopm_get_interface(iface);
203 return 0; 204 return 0;
204} 205}
@@ -209,11 +210,12 @@ static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file)
209 struct usb_interface *iface; 210 struct usb_interface *iface;
210 snd_printdd(KERN_DEBUG "%p %p\n", hw, file); 211 snd_printdd(KERN_DEBUG "%p %p\n", hw, file);
211 212
212 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) { 213 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
213 iface = usb_ifnum_to_if(us122l->chip.dev, 0); 214 us122l->dev->descriptor.idProduct == USB_ID_US144MKII) {
215 iface = usb_ifnum_to_if(us122l->dev, 0);
214 usb_autopm_put_interface(iface); 216 usb_autopm_put_interface(iface);
215 } 217 }
216 iface = usb_ifnum_to_if(us122l->chip.dev, 1); 218 iface = usb_ifnum_to_if(us122l->dev, 1);
217 usb_autopm_put_interface(iface); 219 usb_autopm_put_interface(iface);
218 if (us122l->first == file) 220 if (us122l->first == file)
219 us122l->first = NULL; 221 us122l->first = NULL;
@@ -297,7 +299,7 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw,
297static void us122l_stop(struct us122l *us122l) 299static void us122l_stop(struct us122l *us122l)
298{ 300{
299 struct list_head *p; 301 struct list_head *p;
300 list_for_each(p, &us122l->chip.midi_list) 302 list_for_each(p, &us122l->midi_list)
301 snd_usbmidi_input_stop(p); 303 snd_usbmidi_input_stop(p);
302 304
303 usb_stream_stop(&us122l->sk); 305 usb_stream_stop(&us122l->sk);
@@ -330,7 +332,7 @@ static bool us122l_start(struct us122l *us122l,
330 unsigned use_packsize = 0; 332 unsigned use_packsize = 0;
331 bool success = false; 333 bool success = false;
332 334
333 if (us122l->chip.dev->speed == USB_SPEED_HIGH) { 335 if (us122l->dev->speed == USB_SPEED_HIGH) {
334 /* The us-122l's descriptor defaults to iso max_packsize 78, 336 /* The us-122l's descriptor defaults to iso max_packsize 78,
335 which isn't needed for samplerates <= 48000. 337 which isn't needed for samplerates <= 48000.
336 Lets save some memory: 338 Lets save some memory:
@@ -347,11 +349,11 @@ static bool us122l_start(struct us122l *us122l,
347 break; 349 break;
348 } 350 }
349 } 351 }
350 if (!usb_stream_new(&us122l->sk, us122l->chip.dev, 1, 2, 352 if (!usb_stream_new(&us122l->sk, us122l->dev, 1, 2,
351 rate, use_packsize, period_frames, 6)) 353 rate, use_packsize, period_frames, 6))
352 goto out; 354 goto out;
353 355
354 err = us122l_set_sample_rate(us122l->chip.dev, rate); 356 err = us122l_set_sample_rate(us122l->dev, rate);
355 if (err < 0) { 357 if (err < 0) {
356 us122l_stop(us122l); 358 us122l_stop(us122l);
357 snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); 359 snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
@@ -363,7 +365,7 @@ static bool us122l_start(struct us122l *us122l,
363 snd_printk(KERN_ERR "us122l_start error %i \n", err); 365 snd_printk(KERN_ERR "us122l_start error %i \n", err);
364 goto out; 366 goto out;
365 } 367 }
366 list_for_each(p, &us122l->chip.midi_list) 368 list_for_each(p, &us122l->midi_list)
367 snd_usbmidi_input_start(p); 369 snd_usbmidi_input_start(p);
368 success = true; 370 success = true;
369out: 371out:
@@ -390,7 +392,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
390 err = -ENXIO; 392 err = -ENXIO;
391 goto free; 393 goto free;
392 } 394 }
393 high_speed = us122l->chip.dev->speed == USB_SPEED_HIGH; 395 high_speed = us122l->dev->speed == USB_SPEED_HIGH;
394 if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 && 396 if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 &&
395 (!high_speed || 397 (!high_speed ||
396 (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) || 398 (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) ||
@@ -450,7 +452,7 @@ static int usb_stream_hwdep_new(struct snd_card *card)
450{ 452{
451 int err; 453 int err;
452 struct snd_hwdep *hw; 454 struct snd_hwdep *hw;
453 struct usb_device *dev = US122L(card)->chip.dev; 455 struct usb_device *dev = US122L(card)->dev;
454 456
455 err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw); 457 err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw);
456 if (err < 0) 458 if (err < 0)
@@ -476,26 +478,28 @@ static bool us122l_create_card(struct snd_card *card)
476 int err; 478 int err;
477 struct us122l *us122l = US122L(card); 479 struct us122l *us122l = US122L(card);
478 480
479 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) { 481 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
480 err = usb_set_interface(us122l->chip.dev, 0, 1); 482 us122l->dev->descriptor.idProduct == USB_ID_US144MKII) {
483 err = usb_set_interface(us122l->dev, 0, 1);
481 if (err) { 484 if (err) {
482 snd_printk(KERN_ERR "usb_set_interface error \n"); 485 snd_printk(KERN_ERR "usb_set_interface error \n");
483 return false; 486 return false;
484 } 487 }
485 } 488 }
486 err = usb_set_interface(us122l->chip.dev, 1, 1); 489 err = usb_set_interface(us122l->dev, 1, 1);
487 if (err) { 490 if (err) {
488 snd_printk(KERN_ERR "usb_set_interface error \n"); 491 snd_printk(KERN_ERR "usb_set_interface error \n");
489 return false; 492 return false;
490 } 493 }
491 494
492 pt_info_set(us122l->chip.dev, 0x11); 495 pt_info_set(us122l->dev, 0x11);
493 pt_info_set(us122l->chip.dev, 0x10); 496 pt_info_set(us122l->dev, 0x10);
494 497
495 if (!us122l_start(us122l, 44100, 256)) 498 if (!us122l_start(us122l, 44100, 256))
496 return false; 499 return false;
497 500
498 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) 501 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
502 us122l->dev->descriptor.idProduct == USB_ID_US144MKII)
499 err = us144_create_usbmidi(card); 503 err = us144_create_usbmidi(card);
500 else 504 else
501 err = us122l_create_usbmidi(card); 505 err = us122l_create_usbmidi(card);
@@ -508,7 +512,7 @@ static bool us122l_create_card(struct snd_card *card)
508 if (err < 0) { 512 if (err < 0) {
509/* release the midi resources */ 513/* release the midi resources */
510 struct list_head *p; 514 struct list_head *p;
511 list_for_each(p, &us122l->chip.midi_list) 515 list_for_each(p, &us122l->midi_list)
512 snd_usbmidi_disconnect(p); 516 snd_usbmidi_disconnect(p);
513 517
514 us122l_stop(us122l); 518 us122l_stop(us122l);
@@ -520,7 +524,7 @@ static bool us122l_create_card(struct snd_card *card)
520static void snd_us122l_free(struct snd_card *card) 524static void snd_us122l_free(struct snd_card *card)
521{ 525{
522 struct us122l *us122l = US122L(card); 526 struct us122l *us122l = US122L(card);
523 int index = us122l->chip.index; 527 int index = us122l->card_index;
524 if (index >= 0 && index < SNDRV_CARDS) 528 if (index >= 0 && index < SNDRV_CARDS)
525 snd_us122l_card_used[index] = 0; 529 snd_us122l_card_used[index] = 0;
526} 530}
@@ -540,13 +544,12 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
540 sizeof(struct us122l), &card); 544 sizeof(struct us122l), &card);
541 if (err < 0) 545 if (err < 0)
542 return err; 546 return err;
543 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 547 snd_us122l_card_used[US122L(card)->card_index = dev] = 1;
544 card->private_free = snd_us122l_free; 548 card->private_free = snd_us122l_free;
545 US122L(card)->chip.dev = device; 549 US122L(card)->dev = device;
546 US122L(card)->chip.card = card;
547 mutex_init(&US122L(card)->mutex); 550 mutex_init(&US122L(card)->mutex);
548 init_waitqueue_head(&US122L(card)->sk.sleep); 551 init_waitqueue_head(&US122L(card)->sk.sleep);
549 INIT_LIST_HEAD(&US122L(card)->chip.midi_list); 552 INIT_LIST_HEAD(&US122L(card)->midi_list);
550 strcpy(card->driver, "USB "NAME_ALLCAPS""); 553 strcpy(card->driver, "USB "NAME_ALLCAPS"");
551 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); 554 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
552 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", 555 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)",
@@ -554,8 +557,8 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
554 le16_to_cpu(device->descriptor.idVendor), 557 le16_to_cpu(device->descriptor.idVendor),
555 le16_to_cpu(device->descriptor.idProduct), 558 le16_to_cpu(device->descriptor.idProduct),
556 0, 559 0,
557 US122L(card)->chip.dev->bus->busnum, 560 US122L(card)->dev->bus->busnum,
558 US122L(card)->chip.dev->devnum 561 US122L(card)->dev->devnum
559 ); 562 );
560 *cardp = card; 563 *cardp = card;
561 return 0; 564 return 0;
@@ -598,7 +601,8 @@ static int snd_us122l_probe(struct usb_interface *intf,
598 struct snd_card *card; 601 struct snd_card *card;
599 int err; 602 int err;
600 603
601 if (device->descriptor.idProduct == USB_ID_US144 604 if ((device->descriptor.idProduct == USB_ID_US144 ||
605 device->descriptor.idProduct == USB_ID_US144MKII)
602 && device->speed == USB_SPEED_HIGH) { 606 && device->speed == USB_SPEED_HIGH) {
603 snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n"); 607 snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n");
604 return -ENODEV; 608 return -ENODEV;
@@ -635,16 +639,15 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
635 mutex_lock(&us122l->mutex); 639 mutex_lock(&us122l->mutex);
636 us122l_stop(us122l); 640 us122l_stop(us122l);
637 mutex_unlock(&us122l->mutex); 641 mutex_unlock(&us122l->mutex);
638 us122l->chip.shutdown = 1;
639 642
640/* release the midi resources */ 643/* release the midi resources */
641 list_for_each(p, &us122l->chip.midi_list) { 644 list_for_each(p, &us122l->midi_list) {
642 snd_usbmidi_disconnect(p); 645 snd_usbmidi_disconnect(p);
643 } 646 }
644 647
645 usb_put_intf(usb_ifnum_to_if(us122l->chip.dev, 0)); 648 usb_put_intf(usb_ifnum_to_if(us122l->dev, 0));
646 usb_put_intf(usb_ifnum_to_if(us122l->chip.dev, 1)); 649 usb_put_intf(usb_ifnum_to_if(us122l->dev, 1));
647 usb_put_dev(us122l->chip.dev); 650 usb_put_dev(us122l->dev);
648 651
649 while (atomic_read(&us122l->mmap_count)) 652 while (atomic_read(&us122l->mmap_count))
650 msleep(500); 653 msleep(500);
@@ -667,7 +670,7 @@ static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message)
667 if (!us122l) 670 if (!us122l)
668 return 0; 671 return 0;
669 672
670 list_for_each(p, &us122l->chip.midi_list) 673 list_for_each(p, &us122l->midi_list)
671 snd_usbmidi_input_stop(p); 674 snd_usbmidi_input_stop(p);
672 675
673 mutex_lock(&us122l->mutex); 676 mutex_lock(&us122l->mutex);
@@ -694,23 +697,24 @@ static int snd_us122l_resume(struct usb_interface *intf)
694 697
695 mutex_lock(&us122l->mutex); 698 mutex_lock(&us122l->mutex);
696 /* needed, doesn't restart without: */ 699 /* needed, doesn't restart without: */
697 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) { 700 if (us122l->dev->descriptor.idProduct == USB_ID_US144 ||
698 err = usb_set_interface(us122l->chip.dev, 0, 1); 701 us122l->dev->descriptor.idProduct == USB_ID_US144MKII) {
702 err = usb_set_interface(us122l->dev, 0, 1);
699 if (err) { 703 if (err) {
700 snd_printk(KERN_ERR "usb_set_interface error \n"); 704 snd_printk(KERN_ERR "usb_set_interface error \n");
701 goto unlock; 705 goto unlock;
702 } 706 }
703 } 707 }
704 err = usb_set_interface(us122l->chip.dev, 1, 1); 708 err = usb_set_interface(us122l->dev, 1, 1);
705 if (err) { 709 if (err) {
706 snd_printk(KERN_ERR "usb_set_interface error \n"); 710 snd_printk(KERN_ERR "usb_set_interface error \n");
707 goto unlock; 711 goto unlock;
708 } 712 }
709 713
710 pt_info_set(us122l->chip.dev, 0x11); 714 pt_info_set(us122l->dev, 0x11);
711 pt_info_set(us122l->chip.dev, 0x10); 715 pt_info_set(us122l->dev, 0x10);
712 716
713 err = us122l_set_sample_rate(us122l->chip.dev, 717 err = us122l_set_sample_rate(us122l->dev,
714 us122l->sk.s->cfg.sample_rate); 718 us122l->sk.s->cfg.sample_rate);
715 if (err < 0) { 719 if (err < 0) {
716 snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); 720 snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
@@ -720,7 +724,7 @@ static int snd_us122l_resume(struct usb_interface *intf)
720 if (err) 724 if (err)
721 goto unlock; 725 goto unlock;
722 726
723 list_for_each(p, &us122l->chip.midi_list) 727 list_for_each(p, &us122l->midi_list)
724 snd_usbmidi_input_start(p); 728 snd_usbmidi_input_start(p);
725unlock: 729unlock:
726 mutex_unlock(&us122l->mutex); 730 mutex_unlock(&us122l->mutex);
@@ -739,6 +743,16 @@ static struct usb_device_id snd_us122l_usb_id_table[] = {
739 .idVendor = 0x0644, 743 .idVendor = 0x0644,
740 .idProduct = USB_ID_US144 744 .idProduct = USB_ID_US144
741 }, 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 },
742 { /* terminator */ } 756 { /* terminator */ }
743}; 757};
744 758