aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/usbaudio.c38
-rw-r--r--sound/usb/usbaudio.h7
-rw-r--r--sound/usb/usbmidi.c208
-rw-r--r--sound/usb/usbmixer_maps.c23
-rw-r--r--sound/usb/usbquirks.h23
-rw-r--r--sound/usb/usx2y/us122l.c90
-rw-r--r--sound/usb/usx2y/us122l.h4
-rw-r--r--sound/usb/usx2y/usX2Yhwdep.c8
-rw-r--r--sound/usb/usx2y/usbusx2y.c28
-rw-r--r--sound/usb/usx2y/usbusx2y.h6
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c34
-rw-r--r--sound/usb/usx2y/usx2yhwdeppcm.c8
12 files changed, 318 insertions, 159 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 8db0374e10d5..b074a594c595 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2893,7 +2893,9 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
2893 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || 2893 if ((altsd->bInterfaceClass == USB_CLASS_AUDIO ||
2894 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && 2894 altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) &&
2895 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) { 2895 altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) {
2896 if (snd_usb_create_midi_interface(chip, iface, NULL) < 0) { 2896 int err = snd_usbmidi_create(chip->card, iface,
2897 &chip->midi_list, NULL);
2898 if (err < 0) {
2897 snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j); 2899 snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j);
2898 continue; 2900 continue;
2899 } 2901 }
@@ -3038,12 +3040,11 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
3038 .type = QUIRK_MIDI_FIXED_ENDPOINT, 3040 .type = QUIRK_MIDI_FIXED_ENDPOINT,
3039 .data = &uaxx_ep 3041 .data = &uaxx_ep
3040 }; 3042 };
3041 if (chip->usb_id == USB_ID(0x0582, 0x002b)) 3043 const struct snd_usb_audio_quirk *quirk =
3042 return snd_usb_create_midi_interface(chip, iface, 3044 chip->usb_id == USB_ID(0x0582, 0x002b)
3043 &ua700_quirk); 3045 ? &ua700_quirk : &uaxx_quirk;
3044 else 3046 return snd_usbmidi_create(chip->card, iface,
3045 return snd_usb_create_midi_interface(chip, iface, 3047 &chip->midi_list, quirk);
3046 &uaxx_quirk);
3047 } 3048 }
3048 3049
3049 if (altsd->bNumEndpoints != 1) 3050 if (altsd->bNumEndpoints != 1)
@@ -3370,6 +3371,13 @@ static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
3370 return 0; /* keep this altsetting */ 3371 return 0; /* keep this altsetting */
3371} 3372}
3372 3373
3374static int create_any_midi_quirk(struct snd_usb_audio *chip,
3375 struct usb_interface *intf,
3376 const struct snd_usb_audio_quirk *quirk)
3377{
3378 return snd_usbmidi_create(chip->card, intf, &chip->midi_list, quirk);
3379}
3380
3373/* 3381/*
3374 * audio-interface quirks 3382 * audio-interface quirks
3375 * 3383 *
@@ -3387,14 +3395,14 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip,
3387 static const quirk_func_t quirk_funcs[] = { 3395 static const quirk_func_t quirk_funcs[] = {
3388 [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk, 3396 [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk,
3389 [QUIRK_COMPOSITE] = create_composite_quirk, 3397 [QUIRK_COMPOSITE] = create_composite_quirk,
3390 [QUIRK_MIDI_STANDARD_INTERFACE] = snd_usb_create_midi_interface, 3398 [QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk,
3391 [QUIRK_MIDI_FIXED_ENDPOINT] = snd_usb_create_midi_interface, 3399 [QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk,
3392 [QUIRK_MIDI_YAMAHA] = snd_usb_create_midi_interface, 3400 [QUIRK_MIDI_YAMAHA] = create_any_midi_quirk,
3393 [QUIRK_MIDI_MIDIMAN] = snd_usb_create_midi_interface, 3401 [QUIRK_MIDI_MIDIMAN] = create_any_midi_quirk,
3394 [QUIRK_MIDI_NOVATION] = snd_usb_create_midi_interface, 3402 [QUIRK_MIDI_NOVATION] = create_any_midi_quirk,
3395 [QUIRK_MIDI_FASTLANE] = snd_usb_create_midi_interface, 3403 [QUIRK_MIDI_FASTLANE] = create_any_midi_quirk,
3396 [QUIRK_MIDI_EMAGIC] = snd_usb_create_midi_interface, 3404 [QUIRK_MIDI_EMAGIC] = create_any_midi_quirk,
3397 [QUIRK_MIDI_CME] = snd_usb_create_midi_interface, 3405 [QUIRK_MIDI_CME] = create_any_midi_quirk,
3398 [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, 3406 [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk,
3399 [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, 3407 [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
3400 [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk, 3408 [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk,
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index e9a3a9dca15c..40ba8115fb81 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -132,7 +132,6 @@ struct snd_usb_audio {
132 int pcm_devs; 132 int pcm_devs;
133 133
134 struct list_head midi_list; /* list of midi interfaces */ 134 struct list_head midi_list; /* list of midi interfaces */
135 int next_midi_device;
136 135
137 struct list_head mixer_list; /* list of mixer interfaces */ 136 struct list_head mixer_list; /* list of mixer interfaces */
138}; 137};
@@ -227,8 +226,10 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
227 int ignore_error); 226 int ignore_error);
228void snd_usb_mixer_disconnect(struct list_head *p); 227void snd_usb_mixer_disconnect(struct list_head *p);
229 228
230int snd_usb_create_midi_interface(struct snd_usb_audio *chip, struct usb_interface *iface, 229int snd_usbmidi_create(struct snd_card *card,
231 const struct snd_usb_audio_quirk *quirk); 230 struct usb_interface *iface,
231 struct list_head *midi_list,
232 const struct snd_usb_audio_quirk *quirk);
232void snd_usbmidi_input_stop(struct list_head* p); 233void snd_usbmidi_input_stop(struct list_head* p);
233void snd_usbmidi_input_start(struct list_head* p); 234void snd_usbmidi_input_start(struct list_head* p);
234void snd_usbmidi_disconnect(struct list_head *p); 235void snd_usbmidi_disconnect(struct list_head *p);
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 0eff19ceb7e1..6e89b8368d9a 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * usbmidi.c - ALSA USB MIDI driver 2 * usbmidi.c - ALSA USB MIDI driver
3 * 3 *
4 * Copyright (c) 2002-2007 Clemens Ladisch 4 * Copyright (c) 2002-2009 Clemens Ladisch
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Based on the OSS usb-midi driver by NAGANO Daisuke, 7 * Based on the OSS usb-midi driver by NAGANO Daisuke,
@@ -47,6 +47,7 @@
47#include <linux/usb.h> 47#include <linux/usb.h>
48#include <linux/wait.h> 48#include <linux/wait.h>
49#include <sound/core.h> 49#include <sound/core.h>
50#include <sound/control.h>
50#include <sound/rawmidi.h> 51#include <sound/rawmidi.h>
51#include <sound/asequencer.h> 52#include <sound/asequencer.h>
52#include "usbaudio.h" 53#include "usbaudio.h"
@@ -101,7 +102,8 @@ struct usb_protocol_ops {
101}; 102};
102 103
103struct snd_usb_midi { 104struct snd_usb_midi {
104 struct snd_usb_audio *chip; 105 struct usb_device *dev;
106 struct snd_card *card;
105 struct usb_interface *iface; 107 struct usb_interface *iface;
106 const struct snd_usb_audio_quirk *quirk; 108 const struct snd_usb_audio_quirk *quirk;
107 struct snd_rawmidi *rmidi; 109 struct snd_rawmidi *rmidi;
@@ -109,13 +111,19 @@ struct snd_usb_midi {
109 struct list_head list; 111 struct list_head list;
110 struct timer_list error_timer; 112 struct timer_list error_timer;
111 spinlock_t disc_lock; 113 spinlock_t disc_lock;
114 struct mutex mutex;
115 u32 usb_id;
116 int next_midi_device;
112 117
113 struct snd_usb_midi_endpoint { 118 struct snd_usb_midi_endpoint {
114 struct snd_usb_midi_out_endpoint *out; 119 struct snd_usb_midi_out_endpoint *out;
115 struct snd_usb_midi_in_endpoint *in; 120 struct snd_usb_midi_in_endpoint *in;
116 } endpoints[MIDI_MAX_ENDPOINTS]; 121 } endpoints[MIDI_MAX_ENDPOINTS];
117 unsigned long input_triggered; 122 unsigned long input_triggered;
123 unsigned int opened;
118 unsigned char disconnected; 124 unsigned char disconnected;
125
126 struct snd_kcontrol *roland_load_ctl;
119}; 127};
120 128
121struct snd_usb_midi_out_endpoint { 129struct snd_usb_midi_out_endpoint {
@@ -255,7 +263,7 @@ static void snd_usbmidi_in_urb_complete(struct urb* urb)
255 } 263 }
256 } 264 }
257 265
258 urb->dev = ep->umidi->chip->dev; 266 urb->dev = ep->umidi->dev;
259 snd_usbmidi_submit_urb(urb, GFP_ATOMIC); 267 snd_usbmidi_submit_urb(urb, GFP_ATOMIC);
260} 268}
261 269
@@ -296,7 +304,7 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep)
296 unsigned long flags; 304 unsigned long flags;
297 305
298 spin_lock_irqsave(&ep->buffer_lock, flags); 306 spin_lock_irqsave(&ep->buffer_lock, flags);
299 if (ep->umidi->chip->shutdown) { 307 if (ep->umidi->disconnected) {
300 spin_unlock_irqrestore(&ep->buffer_lock, flags); 308 spin_unlock_irqrestore(&ep->buffer_lock, flags);
301 return; 309 return;
302 } 310 }
@@ -312,7 +320,7 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep)
312 320
313 dump_urb("sending", urb->transfer_buffer, 321 dump_urb("sending", urb->transfer_buffer,
314 urb->transfer_buffer_length); 322 urb->transfer_buffer_length);
315 urb->dev = ep->umidi->chip->dev; 323 urb->dev = ep->umidi->dev;
316 if (snd_usbmidi_submit_urb(urb, GFP_ATOMIC) < 0) 324 if (snd_usbmidi_submit_urb(urb, GFP_ATOMIC) < 0)
317 break; 325 break;
318 ep->active_urbs |= 1 << urb_index; 326 ep->active_urbs |= 1 << urb_index;
@@ -349,7 +357,7 @@ static void snd_usbmidi_error_timer(unsigned long data)
349 if (in && in->error_resubmit) { 357 if (in && in->error_resubmit) {
350 in->error_resubmit = 0; 358 in->error_resubmit = 0;
351 for (j = 0; j < INPUT_URBS; ++j) { 359 for (j = 0; j < INPUT_URBS; ++j) {
352 in->urbs[j]->dev = umidi->chip->dev; 360 in->urbs[j]->dev = umidi->dev;
353 snd_usbmidi_submit_urb(in->urbs[j], GFP_ATOMIC); 361 snd_usbmidi_submit_urb(in->urbs[j], GFP_ATOMIC);
354 } 362 }
355 } 363 }
@@ -369,7 +377,7 @@ static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep,
369 return -ENOMEM; 377 return -ENOMEM;
370 dump_urb("sending", buf, len); 378 dump_urb("sending", buf, len);
371 if (ep->urbs[0].urb) 379 if (ep->urbs[0].urb)
372 err = usb_bulk_msg(ep->umidi->chip->dev, ep->urbs[0].urb->pipe, 380 err = usb_bulk_msg(ep->umidi->dev, ep->urbs[0].urb->pipe,
373 buf, len, NULL, 250); 381 buf, len, NULL, 250);
374 kfree(buf); 382 kfree(buf);
375 return err; 383 return err;
@@ -724,8 +732,7 @@ static void snd_usbmidi_us122l_output(struct snd_usb_midi_out_endpoint *ep,
724 732
725 if (!ep->ports[0].active) 733 if (!ep->ports[0].active)
726 return; 734 return;
727 count = snd_usb_get_speed(ep->umidi->chip->dev) == USB_SPEED_HIGH 735 count = snd_usb_get_speed(ep->umidi->dev) == USB_SPEED_HIGH ? 1 : 2;
728 ? 1 : 2;
729 count = snd_rawmidi_transmit(ep->ports[0].substream, 736 count = snd_rawmidi_transmit(ep->ports[0].substream,
730 urb->transfer_buffer, 737 urb->transfer_buffer,
731 count); 738 count);
@@ -879,6 +886,50 @@ static struct usb_protocol_ops snd_usbmidi_emagic_ops = {
879}; 886};
880 887
881 888
889static void update_roland_altsetting(struct snd_usb_midi* umidi)
890{
891 struct usb_interface *intf;
892 struct usb_host_interface *hostif;
893 struct usb_interface_descriptor *intfd;
894 int is_light_load;
895
896 intf = umidi->iface;
897 is_light_load = intf->cur_altsetting != intf->altsetting;
898 if (umidi->roland_load_ctl->private_value == is_light_load)
899 return;
900 hostif = &intf->altsetting[umidi->roland_load_ctl->private_value];
901 intfd = get_iface_desc(hostif);
902 snd_usbmidi_input_stop(&umidi->list);
903 usb_set_interface(umidi->dev, intfd->bInterfaceNumber,
904 intfd->bAlternateSetting);
905 snd_usbmidi_input_start(&umidi->list);
906}
907
908static void substream_open(struct snd_rawmidi_substream *substream, int open)
909{
910 struct snd_usb_midi* umidi = substream->rmidi->private_data;
911 struct snd_kcontrol *ctl;
912
913 mutex_lock(&umidi->mutex);
914 if (open) {
915 if (umidi->opened++ == 0 && umidi->roland_load_ctl) {
916 ctl = umidi->roland_load_ctl;
917 ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
918 snd_ctl_notify(umidi->card,
919 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
920 update_roland_altsetting(umidi);
921 }
922 } else {
923 if (--umidi->opened == 0 && umidi->roland_load_ctl) {
924 ctl = umidi->roland_load_ctl;
925 ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
926 snd_ctl_notify(umidi->card,
927 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
928 }
929 }
930 mutex_unlock(&umidi->mutex);
931}
932
882static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) 933static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
883{ 934{
884 struct snd_usb_midi* umidi = substream->rmidi->private_data; 935 struct snd_usb_midi* umidi = substream->rmidi->private_data;
@@ -898,11 +949,13 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
898 } 949 }
899 substream->runtime->private_data = port; 950 substream->runtime->private_data = port;
900 port->state = STATE_UNKNOWN; 951 port->state = STATE_UNKNOWN;
952 substream_open(substream, 1);
901 return 0; 953 return 0;
902} 954}
903 955
904static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) 956static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
905{ 957{
958 substream_open(substream, 0);
906 return 0; 959 return 0;
907} 960}
908 961
@@ -912,7 +965,7 @@ static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream,
912 965
913 port->active = up; 966 port->active = up;
914 if (up) { 967 if (up) {
915 if (port->ep->umidi->chip->shutdown) { 968 if (port->ep->umidi->disconnected) {
916 /* gobble up remaining bytes to prevent wait in 969 /* gobble up remaining bytes to prevent wait in
917 * snd_rawmidi_drain_output */ 970 * snd_rawmidi_drain_output */
918 while (!snd_rawmidi_transmit_empty(substream)) 971 while (!snd_rawmidi_transmit_empty(substream))
@@ -954,11 +1007,13 @@ static void snd_usbmidi_output_drain(struct snd_rawmidi_substream *substream)
954 1007
955static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream) 1008static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream)
956{ 1009{
1010 substream_open(substream, 1);
957 return 0; 1011 return 0;
958} 1012}
959 1013
960static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream) 1014static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream)
961{ 1015{
1016 substream_open(substream, 0);
962 return 0; 1017 return 0;
963} 1018}
964 1019
@@ -988,7 +1043,7 @@ static struct snd_rawmidi_ops snd_usbmidi_input_ops = {
988static void free_urb_and_buffer(struct snd_usb_midi *umidi, struct urb *urb, 1043static void free_urb_and_buffer(struct snd_usb_midi *umidi, struct urb *urb,
989 unsigned int buffer_length) 1044 unsigned int buffer_length)
990{ 1045{
991 usb_buffer_free(umidi->chip->dev, buffer_length, 1046 usb_buffer_free(umidi->dev, buffer_length,
992 urb->transfer_buffer, urb->transfer_dma); 1047 urb->transfer_buffer, urb->transfer_dma);
993 usb_free_urb(urb); 1048 usb_free_urb(urb);
994} 1049}
@@ -1035,24 +1090,24 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi,
1035 } 1090 }
1036 } 1091 }
1037 if (ep_info->in_interval) 1092 if (ep_info->in_interval)
1038 pipe = usb_rcvintpipe(umidi->chip->dev, ep_info->in_ep); 1093 pipe = usb_rcvintpipe(umidi->dev, ep_info->in_ep);
1039 else 1094 else
1040 pipe = usb_rcvbulkpipe(umidi->chip->dev, ep_info->in_ep); 1095 pipe = usb_rcvbulkpipe(umidi->dev, ep_info->in_ep);
1041 length = usb_maxpacket(umidi->chip->dev, pipe, 0); 1096 length = usb_maxpacket(umidi->dev, pipe, 0);
1042 for (i = 0; i < INPUT_URBS; ++i) { 1097 for (i = 0; i < INPUT_URBS; ++i) {
1043 buffer = usb_buffer_alloc(umidi->chip->dev, length, GFP_KERNEL, 1098 buffer = usb_buffer_alloc(umidi->dev, length, GFP_KERNEL,
1044 &ep->urbs[i]->transfer_dma); 1099 &ep->urbs[i]->transfer_dma);
1045 if (!buffer) { 1100 if (!buffer) {
1046 snd_usbmidi_in_endpoint_delete(ep); 1101 snd_usbmidi_in_endpoint_delete(ep);
1047 return -ENOMEM; 1102 return -ENOMEM;
1048 } 1103 }
1049 if (ep_info->in_interval) 1104 if (ep_info->in_interval)
1050 usb_fill_int_urb(ep->urbs[i], umidi->chip->dev, 1105 usb_fill_int_urb(ep->urbs[i], umidi->dev,
1051 pipe, buffer, length, 1106 pipe, buffer, length,
1052 snd_usbmidi_in_urb_complete, 1107 snd_usbmidi_in_urb_complete,
1053 ep, ep_info->in_interval); 1108 ep, ep_info->in_interval);
1054 else 1109 else
1055 usb_fill_bulk_urb(ep->urbs[i], umidi->chip->dev, 1110 usb_fill_bulk_urb(ep->urbs[i], umidi->dev,
1056 pipe, buffer, length, 1111 pipe, buffer, length,
1057 snd_usbmidi_in_urb_complete, ep); 1112 snd_usbmidi_in_urb_complete, ep);
1058 ep->urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 1113 ep->urbs[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
@@ -1062,15 +1117,6 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi,
1062 return 0; 1117 return 0;
1063} 1118}
1064 1119
1065static unsigned int snd_usbmidi_count_bits(unsigned int x)
1066{
1067 unsigned int bits;
1068
1069 for (bits = 0; x; ++bits)
1070 x &= x - 1;
1071 return bits;
1072}
1073
1074/* 1120/*
1075 * Frees an output endpoint. 1121 * Frees an output endpoint.
1076 * May be called when ep hasn't been initialized completely. 1122 * May be called when ep hasn't been initialized completely.
@@ -1113,15 +1159,15 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
1113 ep->urbs[i].ep = ep; 1159 ep->urbs[i].ep = ep;
1114 } 1160 }
1115 if (ep_info->out_interval) 1161 if (ep_info->out_interval)
1116 pipe = usb_sndintpipe(umidi->chip->dev, ep_info->out_ep); 1162 pipe = usb_sndintpipe(umidi->dev, ep_info->out_ep);
1117 else 1163 else
1118 pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep); 1164 pipe = usb_sndbulkpipe(umidi->dev, ep_info->out_ep);
1119 if (umidi->chip->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */ 1165 if (umidi->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */
1120 ep->max_transfer = 4; 1166 ep->max_transfer = 4;
1121 else 1167 else
1122 ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1); 1168 ep->max_transfer = usb_maxpacket(umidi->dev, pipe, 1);
1123 for (i = 0; i < OUTPUT_URBS; ++i) { 1169 for (i = 0; i < OUTPUT_URBS; ++i) {
1124 buffer = usb_buffer_alloc(umidi->chip->dev, 1170 buffer = usb_buffer_alloc(umidi->dev,
1125 ep->max_transfer, GFP_KERNEL, 1171 ep->max_transfer, GFP_KERNEL,
1126 &ep->urbs[i].urb->transfer_dma); 1172 &ep->urbs[i].urb->transfer_dma);
1127 if (!buffer) { 1173 if (!buffer) {
@@ -1129,12 +1175,12 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
1129 return -ENOMEM; 1175 return -ENOMEM;
1130 } 1176 }
1131 if (ep_info->out_interval) 1177 if (ep_info->out_interval)
1132 usb_fill_int_urb(ep->urbs[i].urb, umidi->chip->dev, 1178 usb_fill_int_urb(ep->urbs[i].urb, umidi->dev,
1133 pipe, buffer, ep->max_transfer, 1179 pipe, buffer, ep->max_transfer,
1134 snd_usbmidi_out_urb_complete, 1180 snd_usbmidi_out_urb_complete,
1135 &ep->urbs[i], ep_info->out_interval); 1181 &ep->urbs[i], ep_info->out_interval);
1136 else 1182 else
1137 usb_fill_bulk_urb(ep->urbs[i].urb, umidi->chip->dev, 1183 usb_fill_bulk_urb(ep->urbs[i].urb, umidi->dev,
1138 pipe, buffer, ep->max_transfer, 1184 pipe, buffer, ep->max_transfer,
1139 snd_usbmidi_out_urb_complete, 1185 snd_usbmidi_out_urb_complete,
1140 &ep->urbs[i]); 1186 &ep->urbs[i]);
@@ -1172,6 +1218,7 @@ static void snd_usbmidi_free(struct snd_usb_midi* umidi)
1172 if (ep->in) 1218 if (ep->in)
1173 snd_usbmidi_in_endpoint_delete(ep->in); 1219 snd_usbmidi_in_endpoint_delete(ep->in);
1174 } 1220 }
1221 mutex_destroy(&umidi->mutex);
1175 kfree(umidi); 1222 kfree(umidi);
1176} 1223}
1177 1224
@@ -1367,7 +1414,7 @@ static struct port_info *find_port_info(struct snd_usb_midi* umidi, int number)
1367 int i; 1414 int i;
1368 1415
1369 for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_info); ++i) { 1416 for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_info); ++i) {
1370 if (snd_usbmidi_port_info[i].id == umidi->chip->usb_id && 1417 if (snd_usbmidi_port_info[i].id == umidi->usb_id &&
1371 snd_usbmidi_port_info[i].port == number) 1418 snd_usbmidi_port_info[i].port == number)
1372 return &snd_usbmidi_port_info[i]; 1419 return &snd_usbmidi_port_info[i];
1373 } 1420 }
@@ -1405,7 +1452,7 @@ static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi,
1405 port_info = find_port_info(umidi, number); 1452 port_info = find_port_info(umidi, number);
1406 name_format = port_info ? port_info->name : "%s MIDI %d"; 1453 name_format = port_info ? port_info->name : "%s MIDI %d";
1407 snprintf(substream->name, sizeof(substream->name), 1454 snprintf(substream->name, sizeof(substream->name),
1408 name_format, umidi->chip->card->shortname, number + 1); 1455 name_format, umidi->card->shortname, number + 1);
1409 1456
1410 *rsubstream = substream; 1457 *rsubstream = substream;
1411} 1458}
@@ -1503,7 +1550,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1503 endpoints[epidx].out_ep = usb_endpoint_num(ep); 1550 endpoints[epidx].out_ep = usb_endpoint_num(ep);
1504 if (usb_endpoint_xfer_int(ep)) 1551 if (usb_endpoint_xfer_int(ep))
1505 endpoints[epidx].out_interval = ep->bInterval; 1552 endpoints[epidx].out_interval = ep->bInterval;
1506 else if (snd_usb_get_speed(umidi->chip->dev) == USB_SPEED_LOW) 1553 else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW)
1507 /* 1554 /*
1508 * Low speed bulk transfers don't exist, so 1555 * Low speed bulk transfers don't exist, so
1509 * force interrupt transfers for devices like 1556 * force interrupt transfers for devices like
@@ -1523,7 +1570,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1523 endpoints[epidx].in_ep = usb_endpoint_num(ep); 1570 endpoints[epidx].in_ep = usb_endpoint_num(ep);
1524 if (usb_endpoint_xfer_int(ep)) 1571 if (usb_endpoint_xfer_int(ep))
1525 endpoints[epidx].in_interval = ep->bInterval; 1572 endpoints[epidx].in_interval = ep->bInterval;
1526 else if (snd_usb_get_speed(umidi->chip->dev) == USB_SPEED_LOW) 1573 else if (snd_usb_get_speed(umidi->dev) == USB_SPEED_LOW)
1527 endpoints[epidx].in_interval = 1; 1574 endpoints[epidx].in_interval = 1;
1528 endpoints[epidx].in_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1; 1575 endpoints[epidx].in_cables = (1 << ms_ep->bNumEmbMIDIJack) - 1;
1529 snd_printdd(KERN_INFO "EP %02X: %d jack(s)\n", 1576 snd_printdd(KERN_INFO "EP %02X: %d jack(s)\n",
@@ -1533,6 +1580,52 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi,
1533 return 0; 1580 return 0;
1534} 1581}
1535 1582
1583static int roland_load_info(struct snd_kcontrol *kcontrol,
1584 struct snd_ctl_elem_info *info)
1585{
1586 static const char *const names[] = { "High Load", "Light Load" };
1587
1588 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1589 info->count = 1;
1590 info->value.enumerated.items = 2;
1591 if (info->value.enumerated.item > 1)
1592 info->value.enumerated.item = 1;
1593 strcpy(info->value.enumerated.name, names[info->value.enumerated.item]);
1594 return 0;
1595}
1596
1597static int roland_load_get(struct snd_kcontrol *kcontrol,
1598 struct snd_ctl_elem_value *value)
1599{
1600 value->value.enumerated.item[0] = kcontrol->private_value;
1601 return 0;
1602}
1603
1604static int roland_load_put(struct snd_kcontrol *kcontrol,
1605 struct snd_ctl_elem_value *value)
1606{
1607 struct snd_usb_midi* umidi = kcontrol->private_data;
1608 int changed;
1609
1610 if (value->value.enumerated.item[0] > 1)
1611 return -EINVAL;
1612 mutex_lock(&umidi->mutex);
1613 changed = value->value.enumerated.item[0] != kcontrol->private_value;
1614 if (changed)
1615 kcontrol->private_value = value->value.enumerated.item[0];
1616 mutex_unlock(&umidi->mutex);
1617 return changed;
1618}
1619
1620static struct snd_kcontrol_new roland_load_ctl = {
1621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1622 .name = "MIDI Input Mode",
1623 .info = roland_load_info,
1624 .get = roland_load_get,
1625 .put = roland_load_put,
1626 .private_value = 1,
1627};
1628
1536/* 1629/*
1537 * On Roland devices, use the second alternate setting to be able to use 1630 * On Roland devices, use the second alternate setting to be able to use
1538 * the interrupt input endpoint. 1631 * the interrupt input endpoint.
@@ -1556,8 +1649,12 @@ static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi)
1556 1649
1557 snd_printdd(KERN_INFO "switching to altsetting %d with int ep\n", 1650 snd_printdd(KERN_INFO "switching to altsetting %d with int ep\n",
1558 intfd->bAlternateSetting); 1651 intfd->bAlternateSetting);
1559 usb_set_interface(umidi->chip->dev, intfd->bInterfaceNumber, 1652 usb_set_interface(umidi->dev, intfd->bInterfaceNumber,
1560 intfd->bAlternateSetting); 1653 intfd->bAlternateSetting);
1654
1655 umidi->roland_load_ctl = snd_ctl_new1(&roland_load_ctl, umidi);
1656 if (snd_ctl_add(umidi->card, umidi->roland_load_ctl) < 0)
1657 umidi->roland_load_ctl = NULL;
1561} 1658}
1562 1659
1563/* 1660/*
@@ -1573,7 +1670,7 @@ static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi,
1573 struct usb_endpoint_descriptor* epd; 1670 struct usb_endpoint_descriptor* epd;
1574 int i, out_eps = 0, in_eps = 0; 1671 int i, out_eps = 0, in_eps = 0;
1575 1672
1576 if (USB_ID_VENDOR(umidi->chip->usb_id) == 0x0582) 1673 if (USB_ID_VENDOR(umidi->usb_id) == 0x0582)
1577 snd_usbmidi_switch_roland_altsetting(umidi); 1674 snd_usbmidi_switch_roland_altsetting(umidi);
1578 1675
1579 if (endpoint[0].out_ep || endpoint[0].in_ep) 1676 if (endpoint[0].out_ep || endpoint[0].in_ep)
@@ -1760,12 +1857,12 @@ static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi,
1760 struct snd_rawmidi *rmidi; 1857 struct snd_rawmidi *rmidi;
1761 int err; 1858 int err;
1762 1859
1763 err = snd_rawmidi_new(umidi->chip->card, "USB MIDI", 1860 err = snd_rawmidi_new(umidi->card, "USB MIDI",
1764 umidi->chip->next_midi_device++, 1861 umidi->next_midi_device++,
1765 out_ports, in_ports, &rmidi); 1862 out_ports, in_ports, &rmidi);
1766 if (err < 0) 1863 if (err < 0)
1767 return err; 1864 return err;
1768 strcpy(rmidi->name, umidi->chip->card->shortname); 1865 strcpy(rmidi->name, umidi->card->shortname);
1769 rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT | 1866 rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT |
1770 SNDRV_RAWMIDI_INFO_INPUT | 1867 SNDRV_RAWMIDI_INFO_INPUT |
1771 SNDRV_RAWMIDI_INFO_DUPLEX; 1868 SNDRV_RAWMIDI_INFO_DUPLEX;
@@ -1804,7 +1901,7 @@ static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep)
1804 return; 1901 return;
1805 for (i = 0; i < INPUT_URBS; ++i) { 1902 for (i = 0; i < INPUT_URBS; ++i) {
1806 struct urb* urb = ep->urbs[i]; 1903 struct urb* urb = ep->urbs[i];
1807 urb->dev = ep->umidi->chip->dev; 1904 urb->dev = ep->umidi->dev;
1808 snd_usbmidi_submit_urb(urb, GFP_KERNEL); 1905 snd_usbmidi_submit_urb(urb, GFP_KERNEL);
1809 } 1906 }
1810} 1907}
@@ -1825,9 +1922,10 @@ void snd_usbmidi_input_start(struct list_head* p)
1825/* 1922/*
1826 * Creates and registers everything needed for a MIDI streaming interface. 1923 * Creates and registers everything needed for a MIDI streaming interface.
1827 */ 1924 */
1828int snd_usb_create_midi_interface(struct snd_usb_audio* chip, 1925int snd_usbmidi_create(struct snd_card *card,
1829 struct usb_interface* iface, 1926 struct usb_interface* iface,
1830 const struct snd_usb_audio_quirk* quirk) 1927 struct list_head *midi_list,
1928 const struct snd_usb_audio_quirk* quirk)
1831{ 1929{
1832 struct snd_usb_midi* umidi; 1930 struct snd_usb_midi* umidi;
1833 struct snd_usb_midi_endpoint_info endpoints[MIDI_MAX_ENDPOINTS]; 1931 struct snd_usb_midi_endpoint_info endpoints[MIDI_MAX_ENDPOINTS];
@@ -1837,12 +1935,16 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip,
1837 umidi = kzalloc(sizeof(*umidi), GFP_KERNEL); 1935 umidi = kzalloc(sizeof(*umidi), GFP_KERNEL);
1838 if (!umidi) 1936 if (!umidi)
1839 return -ENOMEM; 1937 return -ENOMEM;
1840 umidi->chip = chip; 1938 umidi->dev = interface_to_usbdev(iface);
1939 umidi->card = card;
1841 umidi->iface = iface; 1940 umidi->iface = iface;
1842 umidi->quirk = quirk; 1941 umidi->quirk = quirk;
1843 umidi->usb_protocol_ops = &snd_usbmidi_standard_ops; 1942 umidi->usb_protocol_ops = &snd_usbmidi_standard_ops;
1844 init_timer(&umidi->error_timer); 1943 init_timer(&umidi->error_timer);
1845 spin_lock_init(&umidi->disc_lock); 1944 spin_lock_init(&umidi->disc_lock);
1945 mutex_init(&umidi->mutex);
1946 umidi->usb_id = USB_ID(le16_to_cpu(umidi->dev->descriptor.idVendor),
1947 le16_to_cpu(umidi->dev->descriptor.idProduct));
1846 umidi->error_timer.function = snd_usbmidi_error_timer; 1948 umidi->error_timer.function = snd_usbmidi_error_timer;
1847 umidi->error_timer.data = (unsigned long)umidi; 1949 umidi->error_timer.data = (unsigned long)umidi;
1848 1950
@@ -1851,7 +1953,7 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip,
1851 switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) { 1953 switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) {
1852 case QUIRK_MIDI_STANDARD_INTERFACE: 1954 case QUIRK_MIDI_STANDARD_INTERFACE:
1853 err = snd_usbmidi_get_ms_info(umidi, endpoints); 1955 err = snd_usbmidi_get_ms_info(umidi, endpoints);
1854 if (chip->usb_id == USB_ID(0x0763, 0x0150)) /* M-Audio Uno */ 1956 if (umidi->usb_id == USB_ID(0x0763, 0x0150)) /* M-Audio Uno */
1855 umidi->usb_protocol_ops = 1957 umidi->usb_protocol_ops =
1856 &snd_usbmidi_maudio_broken_running_status_ops; 1958 &snd_usbmidi_maudio_broken_running_status_ops;
1857 break; 1959 break;
@@ -1887,7 +1989,7 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip,
1887 * interface 0, so we have to make sure that the USB core looks 1989 * interface 0, so we have to make sure that the USB core looks
1888 * again at interface 0 by calling usb_set_interface() on it. 1990 * again at interface 0 by calling usb_set_interface() on it.
1889 */ 1991 */
1890 usb_set_interface(umidi->chip->dev, 0, 0); 1992 usb_set_interface(umidi->dev, 0, 0);
1891 err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints); 1993 err = snd_usbmidi_detect_per_port_endpoints(umidi, endpoints);
1892 break; 1994 break;
1893 case QUIRK_MIDI_EMAGIC: 1995 case QUIRK_MIDI_EMAGIC:
@@ -1914,8 +2016,8 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip,
1914 out_ports = 0; 2016 out_ports = 0;
1915 in_ports = 0; 2017 in_ports = 0;
1916 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { 2018 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
1917 out_ports += snd_usbmidi_count_bits(endpoints[i].out_cables); 2019 out_ports += hweight16(endpoints[i].out_cables);
1918 in_ports += snd_usbmidi_count_bits(endpoints[i].in_cables); 2020 in_ports += hweight16(endpoints[i].in_cables);
1919 } 2021 }
1920 err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports); 2022 err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports);
1921 if (err < 0) { 2023 if (err < 0) {
@@ -1933,14 +2035,14 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip,
1933 return err; 2035 return err;
1934 } 2036 }
1935 2037
1936 list_add(&umidi->list, &umidi->chip->midi_list); 2038 list_add_tail(&umidi->list, midi_list);
1937 2039
1938 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) 2040 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
1939 snd_usbmidi_input_start_ep(umidi->endpoints[i].in); 2041 snd_usbmidi_input_start_ep(umidi->endpoints[i].in);
1940 return 0; 2042 return 0;
1941} 2043}
1942 2044
1943EXPORT_SYMBOL(snd_usb_create_midi_interface); 2045EXPORT_SYMBOL(snd_usbmidi_create);
1944EXPORT_SYMBOL(snd_usbmidi_input_stop); 2046EXPORT_SYMBOL(snd_usbmidi_input_stop);
1945EXPORT_SYMBOL(snd_usbmidi_input_start); 2047EXPORT_SYMBOL(snd_usbmidi_input_start);
1946EXPORT_SYMBOL(snd_usbmidi_disconnect); 2048EXPORT_SYMBOL(snd_usbmidi_disconnect);
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c
index 3e5d66cf1f5a..77c35885e21c 100644
--- a/sound/usb/usbmixer_maps.c
+++ b/sound/usb/usbmixer_maps.c
@@ -277,6 +277,22 @@ static struct usbmix_name_map scratch_live_map[] = {
277 { 0 } /* terminator */ 277 { 0 } /* terminator */
278}; 278};
279 279
280/* "Gamesurround Muse Pocket LT" looks same like "Sound Blaster MP3+"
281 * most importand difference is SU[8], it should be set to "Capture Source"
282 * to make alsamixer and PA working properly.
283 * FIXME: or mp3plus_map should use "Capture Source" too,
284 * so this maps can be merget
285 */
286static struct usbmix_name_map hercules_usb51_map[] = {
287 { 8, "Capture Source" }, /* SU, default "PCM Capture Source" */
288 { 9, "Master Playback" }, /* FU, default "Speaker Playback" */
289 { 10, "Mic Boost", 7 }, /* FU, default "Auto Gain Input" */
290 { 11, "Line Capture" }, /* FU, default "PCM Capture" */
291 { 13, "Mic Bypass Playback" }, /* FU, default "Mic Playback" */
292 { 14, "Line Bypass Playback" }, /* FU, default "Line Playback" */
293 { 0 } /* terminator */
294};
295
280/* 296/*
281 * Control map entries 297 * Control map entries
282 */ 298 */
@@ -316,6 +332,13 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
316 .ignore_ctl_error = 1, 332 .ignore_ctl_error = 1,
317 }, 333 },
318 { 334 {
335 /* Hercules Gamesurround Muse Pocket LT
336 * (USB 5.1 Channel Audio Adapter)
337 */
338 .id = USB_ID(0x06f8, 0xc000),
339 .map = hercules_usb51_map,
340 },
341 {
319 .id = USB_ID(0x08bb, 0x2702), 342 .id = USB_ID(0x08bb, 0x2702),
320 .map = linex_map, 343 .map = linex_map,
321 .ignore_ctl_error = 1, 344 .ignore_ctl_error = 1,
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index f6f201eb24ce..a892bda03df9 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -1563,6 +1563,29 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1563 } 1563 }
1564 } 1564 }
1565}, 1565},
1566{
1567 /* has ID 0x00ea when not in Advanced Driver mode */
1568 USB_DEVICE_VENDOR_SPEC(0x0582, 0x00e9),
1569 .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
1570 /* .vendor_name = "Roland", */
1571 /* .product_name = "UA-1G", */
1572 .ifnum = QUIRK_ANY_INTERFACE,
1573 .type = QUIRK_COMPOSITE,
1574 .data = (const struct snd_usb_audio_quirk[]) {
1575 {
1576 .ifnum = 0,
1577 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1578 },
1579 {
1580 .ifnum = 1,
1581 .type = QUIRK_AUDIO_STANDARD_INTERFACE
1582 },
1583 {
1584 .ifnum = -1
1585 }
1586 }
1587 }
1588},
1566 1589
1567/* Guillemot devices */ 1590/* Guillemot devices */
1568{ 1591{
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 00cd54c236b4..f71cd28eca6b 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,11 @@ 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 iface = usb_ifnum_to_if(us122l->dev, 0);
199 usb_autopm_get_interface(iface); 199 usb_autopm_get_interface(iface);
200 } 200 }
201 iface = usb_ifnum_to_if(us122l->chip.dev, 1); 201 iface = usb_ifnum_to_if(us122l->dev, 1);
202 usb_autopm_get_interface(iface); 202 usb_autopm_get_interface(iface);
203 return 0; 203 return 0;
204} 204}
@@ -209,11 +209,11 @@ static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file *file)
209 struct usb_interface *iface; 209 struct usb_interface *iface;
210 snd_printdd(KERN_DEBUG "%p %p\n", hw, file); 210 snd_printdd(KERN_DEBUG "%p %p\n", hw, file);
211 211
212 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) { 212 if (us122l->dev->descriptor.idProduct == USB_ID_US144) {
213 iface = usb_ifnum_to_if(us122l->chip.dev, 0); 213 iface = usb_ifnum_to_if(us122l->dev, 0);
214 usb_autopm_put_interface(iface); 214 usb_autopm_put_interface(iface);
215 } 215 }
216 iface = usb_ifnum_to_if(us122l->chip.dev, 1); 216 iface = usb_ifnum_to_if(us122l->dev, 1);
217 usb_autopm_put_interface(iface); 217 usb_autopm_put_interface(iface);
218 if (us122l->first == file) 218 if (us122l->first == file)
219 us122l->first = NULL; 219 us122l->first = NULL;
@@ -297,7 +297,7 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw,
297static void us122l_stop(struct us122l *us122l) 297static void us122l_stop(struct us122l *us122l)
298{ 298{
299 struct list_head *p; 299 struct list_head *p;
300 list_for_each(p, &us122l->chip.midi_list) 300 list_for_each(p, &us122l->midi_list)
301 snd_usbmidi_input_stop(p); 301 snd_usbmidi_input_stop(p);
302 302
303 usb_stream_stop(&us122l->sk); 303 usb_stream_stop(&us122l->sk);
@@ -330,7 +330,7 @@ static bool us122l_start(struct us122l *us122l,
330 unsigned use_packsize = 0; 330 unsigned use_packsize = 0;
331 bool success = false; 331 bool success = false;
332 332
333 if (us122l->chip.dev->speed == USB_SPEED_HIGH) { 333 if (us122l->dev->speed == USB_SPEED_HIGH) {
334 /* The us-122l's descriptor defaults to iso max_packsize 78, 334 /* The us-122l's descriptor defaults to iso max_packsize 78,
335 which isn't needed for samplerates <= 48000. 335 which isn't needed for samplerates <= 48000.
336 Lets save some memory: 336 Lets save some memory:
@@ -347,11 +347,11 @@ static bool us122l_start(struct us122l *us122l,
347 break; 347 break;
348 } 348 }
349 } 349 }
350 if (!usb_stream_new(&us122l->sk, us122l->chip.dev, 1, 2, 350 if (!usb_stream_new(&us122l->sk, us122l->dev, 1, 2,
351 rate, use_packsize, period_frames, 6)) 351 rate, use_packsize, period_frames, 6))
352 goto out; 352 goto out;
353 353
354 err = us122l_set_sample_rate(us122l->chip.dev, rate); 354 err = us122l_set_sample_rate(us122l->dev, rate);
355 if (err < 0) { 355 if (err < 0) {
356 us122l_stop(us122l); 356 us122l_stop(us122l);
357 snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); 357 snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
@@ -363,7 +363,7 @@ static bool us122l_start(struct us122l *us122l,
363 snd_printk(KERN_ERR "us122l_start error %i \n", err); 363 snd_printk(KERN_ERR "us122l_start error %i \n", err);
364 goto out; 364 goto out;
365 } 365 }
366 list_for_each(p, &us122l->chip.midi_list) 366 list_for_each(p, &us122l->midi_list)
367 snd_usbmidi_input_start(p); 367 snd_usbmidi_input_start(p);
368 success = true; 368 success = true;
369out: 369out:
@@ -390,7 +390,7 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
390 err = -ENXIO; 390 err = -ENXIO;
391 goto free; 391 goto free;
392 } 392 }
393 high_speed = us122l->chip.dev->speed == USB_SPEED_HIGH; 393 high_speed = us122l->dev->speed == USB_SPEED_HIGH;
394 if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 && 394 if ((cfg->sample_rate != 44100 && cfg->sample_rate != 48000 &&
395 (!high_speed || 395 (!high_speed ||
396 (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) || 396 (cfg->sample_rate != 88200 && cfg->sample_rate != 96000))) ||
@@ -450,7 +450,7 @@ static int usb_stream_hwdep_new(struct snd_card *card)
450{ 450{
451 int err; 451 int err;
452 struct snd_hwdep *hw; 452 struct snd_hwdep *hw;
453 struct usb_device *dev = US122L(card)->chip.dev; 453 struct usb_device *dev = US122L(card)->dev;
454 454
455 err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw); 455 err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw);
456 if (err < 0) 456 if (err < 0)
@@ -476,26 +476,26 @@ static bool us122l_create_card(struct snd_card *card)
476 int err; 476 int err;
477 struct us122l *us122l = US122L(card); 477 struct us122l *us122l = US122L(card);
478 478
479 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) { 479 if (us122l->dev->descriptor.idProduct == USB_ID_US144) {
480 err = usb_set_interface(us122l->chip.dev, 0, 1); 480 err = usb_set_interface(us122l->dev, 0, 1);
481 if (err) { 481 if (err) {
482 snd_printk(KERN_ERR "usb_set_interface error \n"); 482 snd_printk(KERN_ERR "usb_set_interface error \n");
483 return false; 483 return false;
484 } 484 }
485 } 485 }
486 err = usb_set_interface(us122l->chip.dev, 1, 1); 486 err = usb_set_interface(us122l->dev, 1, 1);
487 if (err) { 487 if (err) {
488 snd_printk(KERN_ERR "usb_set_interface error \n"); 488 snd_printk(KERN_ERR "usb_set_interface error \n");
489 return false; 489 return false;
490 } 490 }
491 491
492 pt_info_set(us122l->chip.dev, 0x11); 492 pt_info_set(us122l->dev, 0x11);
493 pt_info_set(us122l->chip.dev, 0x10); 493 pt_info_set(us122l->dev, 0x10);
494 494
495 if (!us122l_start(us122l, 44100, 256)) 495 if (!us122l_start(us122l, 44100, 256))
496 return false; 496 return false;
497 497
498 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) 498 if (us122l->dev->descriptor.idProduct == USB_ID_US144)
499 err = us144_create_usbmidi(card); 499 err = us144_create_usbmidi(card);
500 else 500 else
501 err = us122l_create_usbmidi(card); 501 err = us122l_create_usbmidi(card);
@@ -508,7 +508,7 @@ static bool us122l_create_card(struct snd_card *card)
508 if (err < 0) { 508 if (err < 0) {
509/* release the midi resources */ 509/* release the midi resources */
510 struct list_head *p; 510 struct list_head *p;
511 list_for_each(p, &us122l->chip.midi_list) 511 list_for_each(p, &us122l->midi_list)
512 snd_usbmidi_disconnect(p); 512 snd_usbmidi_disconnect(p);
513 513
514 us122l_stop(us122l); 514 us122l_stop(us122l);
@@ -520,7 +520,7 @@ static bool us122l_create_card(struct snd_card *card)
520static void snd_us122l_free(struct snd_card *card) 520static void snd_us122l_free(struct snd_card *card)
521{ 521{
522 struct us122l *us122l = US122L(card); 522 struct us122l *us122l = US122L(card);
523 int index = us122l->chip.index; 523 int index = us122l->card_index;
524 if (index >= 0 && index < SNDRV_CARDS) 524 if (index >= 0 && index < SNDRV_CARDS)
525 snd_us122l_card_used[index] = 0; 525 snd_us122l_card_used[index] = 0;
526} 526}
@@ -540,13 +540,12 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
540 sizeof(struct us122l), &card); 540 sizeof(struct us122l), &card);
541 if (err < 0) 541 if (err < 0)
542 return err; 542 return err;
543 snd_us122l_card_used[US122L(card)->chip.index = dev] = 1; 543 snd_us122l_card_used[US122L(card)->card_index = dev] = 1;
544 card->private_free = snd_us122l_free; 544 card->private_free = snd_us122l_free;
545 US122L(card)->chip.dev = device; 545 US122L(card)->dev = device;
546 US122L(card)->chip.card = card;
547 mutex_init(&US122L(card)->mutex); 546 mutex_init(&US122L(card)->mutex);
548 init_waitqueue_head(&US122L(card)->sk.sleep); 547 init_waitqueue_head(&US122L(card)->sk.sleep);
549 INIT_LIST_HEAD(&US122L(card)->chip.midi_list); 548 INIT_LIST_HEAD(&US122L(card)->midi_list);
550 strcpy(card->driver, "USB "NAME_ALLCAPS""); 549 strcpy(card->driver, "USB "NAME_ALLCAPS"");
551 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); 550 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
552 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", 551 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)",
@@ -554,8 +553,8 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
554 le16_to_cpu(device->descriptor.idVendor), 553 le16_to_cpu(device->descriptor.idVendor),
555 le16_to_cpu(device->descriptor.idProduct), 554 le16_to_cpu(device->descriptor.idProduct),
556 0, 555 0,
557 US122L(card)->chip.dev->bus->busnum, 556 US122L(card)->dev->bus->busnum,
558 US122L(card)->chip.dev->devnum 557 US122L(card)->dev->devnum
559 ); 558 );
560 *cardp = card; 559 *cardp = card;
561 return 0; 560 return 0;
@@ -635,16 +634,15 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
635 mutex_lock(&us122l->mutex); 634 mutex_lock(&us122l->mutex);
636 us122l_stop(us122l); 635 us122l_stop(us122l);
637 mutex_unlock(&us122l->mutex); 636 mutex_unlock(&us122l->mutex);
638 us122l->chip.shutdown = 1;
639 637
640/* release the midi resources */ 638/* release the midi resources */
641 list_for_each(p, &us122l->chip.midi_list) { 639 list_for_each(p, &us122l->midi_list) {
642 snd_usbmidi_disconnect(p); 640 snd_usbmidi_disconnect(p);
643 } 641 }
644 642
645 usb_put_intf(usb_ifnum_to_if(us122l->chip.dev, 0)); 643 usb_put_intf(usb_ifnum_to_if(us122l->dev, 0));
646 usb_put_intf(usb_ifnum_to_if(us122l->chip.dev, 1)); 644 usb_put_intf(usb_ifnum_to_if(us122l->dev, 1));
647 usb_put_dev(us122l->chip.dev); 645 usb_put_dev(us122l->dev);
648 646
649 while (atomic_read(&us122l->mmap_count)) 647 while (atomic_read(&us122l->mmap_count))
650 msleep(500); 648 msleep(500);
@@ -667,7 +665,7 @@ static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message)
667 if (!us122l) 665 if (!us122l)
668 return 0; 666 return 0;
669 667
670 list_for_each(p, &us122l->chip.midi_list) 668 list_for_each(p, &us122l->midi_list)
671 snd_usbmidi_input_stop(p); 669 snd_usbmidi_input_stop(p);
672 670
673 mutex_lock(&us122l->mutex); 671 mutex_lock(&us122l->mutex);
@@ -694,23 +692,23 @@ static int snd_us122l_resume(struct usb_interface *intf)
694 692
695 mutex_lock(&us122l->mutex); 693 mutex_lock(&us122l->mutex);
696 /* needed, doesn't restart without: */ 694 /* needed, doesn't restart without: */
697 if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) { 695 if (us122l->dev->descriptor.idProduct == USB_ID_US144) {
698 err = usb_set_interface(us122l->chip.dev, 0, 1); 696 err = usb_set_interface(us122l->dev, 0, 1);
699 if (err) { 697 if (err) {
700 snd_printk(KERN_ERR "usb_set_interface error \n"); 698 snd_printk(KERN_ERR "usb_set_interface error \n");
701 goto unlock; 699 goto unlock;
702 } 700 }
703 } 701 }
704 err = usb_set_interface(us122l->chip.dev, 1, 1); 702 err = usb_set_interface(us122l->dev, 1, 1);
705 if (err) { 703 if (err) {
706 snd_printk(KERN_ERR "usb_set_interface error \n"); 704 snd_printk(KERN_ERR "usb_set_interface error \n");
707 goto unlock; 705 goto unlock;
708 } 706 }
709 707
710 pt_info_set(us122l->chip.dev, 0x11); 708 pt_info_set(us122l->dev, 0x11);
711 pt_info_set(us122l->chip.dev, 0x10); 709 pt_info_set(us122l->dev, 0x10);
712 710
713 err = us122l_set_sample_rate(us122l->chip.dev, 711 err = us122l_set_sample_rate(us122l->dev,
714 us122l->sk.s->cfg.sample_rate); 712 us122l->sk.s->cfg.sample_rate);
715 if (err < 0) { 713 if (err < 0) {
716 snd_printk(KERN_ERR "us122l_set_sample_rate error \n"); 714 snd_printk(KERN_ERR "us122l_set_sample_rate error \n");
@@ -720,7 +718,7 @@ static int snd_us122l_resume(struct usb_interface *intf)
720 if (err) 718 if (err)
721 goto unlock; 719 goto unlock;
722 720
723 list_for_each(p, &us122l->chip.midi_list) 721 list_for_each(p, &us122l->midi_list)
724 snd_usbmidi_input_start(p); 722 snd_usbmidi_input_start(p);
725unlock: 723unlock:
726 mutex_unlock(&us122l->mutex); 724 mutex_unlock(&us122l->mutex);
diff --git a/sound/usb/usx2y/us122l.h b/sound/usb/usx2y/us122l.h
index 3d10c4b2a0f5..4daf1982e821 100644
--- a/sound/usb/usx2y/us122l.h
+++ b/sound/usb/usx2y/us122l.h
@@ -3,7 +3,8 @@
3 3
4 4
5struct us122l { 5struct us122l {
6 struct snd_usb_audio chip; 6 struct usb_device *dev;
7 int card_index;
7 int stride; 8 int stride;
8 struct usb_stream_kernel sk; 9 struct usb_stream_kernel sk;
9 10
@@ -12,6 +13,7 @@ struct us122l {
12 unsigned second_periods_polled; 13 unsigned second_periods_polled;
13 struct file *master; 14 struct file *master;
14 struct file *slave; 15 struct file *slave;
16 struct list_head midi_list;
15 17
16 atomic_t mmap_count; 18 atomic_t mmap_count;
17}; 19};
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c
index 52e04b2f35d3..1879b72c40f8 100644
--- a/sound/usb/usx2y/usX2Yhwdep.c
+++ b/sound/usb/usx2y/usX2Yhwdep.c
@@ -114,7 +114,7 @@ static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw,
114 struct usX2Ydev *us428 = hw->private_data; 114 struct usX2Ydev *us428 = hw->private_data;
115 int id = -1; 115 int id = -1;
116 116
117 switch (le16_to_cpu(us428->chip.dev->descriptor.idProduct)) { 117 switch (le16_to_cpu(us428->dev->descriptor.idProduct)) {
118 case USB_ID_US122: 118 case USB_ID_US122:
119 id = USX2Y_TYPE_122; 119 id = USX2Y_TYPE_122;
120 break; 120 break;
@@ -164,14 +164,14 @@ static int usX2Y_create_usbmidi(struct snd_card *card)
164 .type = QUIRK_MIDI_FIXED_ENDPOINT, 164 .type = QUIRK_MIDI_FIXED_ENDPOINT,
165 .data = &quirk_data_2 165 .data = &quirk_data_2
166 }; 166 };
167 struct usb_device *dev = usX2Y(card)->chip.dev; 167 struct usb_device *dev = usX2Y(card)->dev;
168 struct usb_interface *iface = usb_ifnum_to_if(dev, 0); 168 struct usb_interface *iface = usb_ifnum_to_if(dev, 0);
169 struct snd_usb_audio_quirk *quirk = 169 struct snd_usb_audio_quirk *quirk =
170 le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? 170 le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ?
171 &quirk_2 : &quirk_1; 171 &quirk_2 : &quirk_1;
172 172
173 snd_printdd("usX2Y_create_usbmidi \n"); 173 snd_printdd("usX2Y_create_usbmidi \n");
174 return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); 174 return snd_usbmidi_create(card, iface, &usX2Y(card)->midi_list, quirk);
175} 175}
176 176
177static int usX2Y_create_alsa_devices(struct snd_card *card) 177static int usX2Y_create_alsa_devices(struct snd_card *card)
@@ -202,7 +202,7 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw,
202 snd_printdd( "dsp_load %s\n", dsp->name); 202 snd_printdd( "dsp_load %s\n", dsp->name);
203 203
204 if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { 204 if (access_ok(VERIFY_READ, dsp->image, dsp->length)) {
205 struct usb_device* dev = priv->chip.dev; 205 struct usb_device* dev = priv->dev;
206 char *buf; 206 char *buf;
207 207
208 buf = memdup_user(dsp->image, dsp->length); 208 buf = memdup_user(dsp->image, dsp->length);
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index cb4bb8373ca2..c42350eed2eb 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -239,8 +239,8 @@ static void i_usX2Y_In04Int(struct urb *urb)
239 for (j = 0; j < URBS_AsyncSeq && !err; ++j) 239 for (j = 0; j < URBS_AsyncSeq && !err; ++j)
240 if (0 == usX2Y->AS04.urb[j]->status) { 240 if (0 == usX2Y->AS04.urb[j]->status) {
241 struct us428_p4out *p4out = us428ctls->p4out + send; // FIXME if more than 1 p4out is new, 1 gets lost. 241 struct us428_p4out *p4out = us428ctls->p4out + send; // FIXME if more than 1 p4out is new, 1 gets lost.
242 usb_fill_bulk_urb(usX2Y->AS04.urb[j], usX2Y->chip.dev, 242 usb_fill_bulk_urb(usX2Y->AS04.urb[j], usX2Y->dev,
243 usb_sndbulkpipe(usX2Y->chip.dev, 0x04), &p4out->val.vol, 243 usb_sndbulkpipe(usX2Y->dev, 0x04), &p4out->val.vol,
244 p4out->type == eLT_Light ? sizeof(struct us428_lights) : 5, 244 p4out->type == eLT_Light ? sizeof(struct us428_lights) : 5,
245 i_usX2Y_Out04Int, usX2Y); 245 i_usX2Y_Out04Int, usX2Y);
246 err = usb_submit_urb(usX2Y->AS04.urb[j], GFP_ATOMIC); 246 err = usb_submit_urb(usX2Y->AS04.urb[j], GFP_ATOMIC);
@@ -253,7 +253,7 @@ static void i_usX2Y_In04Int(struct urb *urb)
253 if (err) 253 if (err)
254 snd_printk(KERN_ERR "In04Int() usb_submit_urb err=%i\n", err); 254 snd_printk(KERN_ERR "In04Int() usb_submit_urb err=%i\n", err);
255 255
256 urb->dev = usX2Y->chip.dev; 256 urb->dev = usX2Y->dev;
257 usb_submit_urb(urb, GFP_ATOMIC); 257 usb_submit_urb(urb, GFP_ATOMIC);
258} 258}
259 259
@@ -273,8 +273,8 @@ int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y)
273 err = -ENOMEM; 273 err = -ENOMEM;
274 break; 274 break;
275 } 275 }
276 usb_fill_bulk_urb( usX2Y->AS04.urb[i], usX2Y->chip.dev, 276 usb_fill_bulk_urb( usX2Y->AS04.urb[i], usX2Y->dev,
277 usb_sndbulkpipe(usX2Y->chip.dev, 0x04), 277 usb_sndbulkpipe(usX2Y->dev, 0x04),
278 usX2Y->AS04.buffer + URB_DataLen_AsyncSeq*i, 0, 278 usX2Y->AS04.buffer + URB_DataLen_AsyncSeq*i, 0,
279 i_usX2Y_Out04Int, usX2Y 279 i_usX2Y_Out04Int, usX2Y
280 ); 280 );
@@ -293,7 +293,7 @@ int usX2Y_In04_init(struct usX2Ydev *usX2Y)
293 } 293 }
294 294
295 init_waitqueue_head(&usX2Y->In04WaitQueue); 295 init_waitqueue_head(&usX2Y->In04WaitQueue);
296 usb_fill_int_urb(usX2Y->In04urb, usX2Y->chip.dev, usb_rcvintpipe(usX2Y->chip.dev, 0x4), 296 usb_fill_int_urb(usX2Y->In04urb, usX2Y->dev, usb_rcvintpipe(usX2Y->dev, 0x4),
297 usX2Y->In04Buf, 21, 297 usX2Y->In04Buf, 21,
298 i_usX2Y_In04Int, usX2Y, 298 i_usX2Y_In04Int, usX2Y,
299 10); 299 10);
@@ -348,13 +348,12 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
348 sizeof(struct usX2Ydev), &card); 348 sizeof(struct usX2Ydev), &card);
349 if (err < 0) 349 if (err < 0)
350 return err; 350 return err;
351 snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; 351 snd_usX2Y_card_used[usX2Y(card)->card_index = dev] = 1;
352 card->private_free = snd_usX2Y_card_private_free; 352 card->private_free = snd_usX2Y_card_private_free;
353 usX2Y(card)->chip.dev = device; 353 usX2Y(card)->dev = device;
354 usX2Y(card)->chip.card = card;
355 init_waitqueue_head(&usX2Y(card)->prepare_wait_queue); 354 init_waitqueue_head(&usX2Y(card)->prepare_wait_queue);
356 mutex_init(&usX2Y(card)->prepare_mutex); 355 mutex_init(&usX2Y(card)->prepare_mutex);
357 INIT_LIST_HEAD(&usX2Y(card)->chip.midi_list); 356 INIT_LIST_HEAD(&usX2Y(card)->midi_list);
358 strcpy(card->driver, "USB "NAME_ALLCAPS""); 357 strcpy(card->driver, "USB "NAME_ALLCAPS"");
359 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); 358 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
360 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", 359 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)",
@@ -362,7 +361,7 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
362 le16_to_cpu(device->descriptor.idVendor), 361 le16_to_cpu(device->descriptor.idVendor),
363 le16_to_cpu(device->descriptor.idProduct), 362 le16_to_cpu(device->descriptor.idProduct),
364 0,//us428(card)->usbmidi.ifnum, 363 0,//us428(card)->usbmidi.ifnum,
365 usX2Y(card)->chip.dev->bus->busnum, usX2Y(card)->chip.dev->devnum 364 usX2Y(card)->dev->bus->busnum, usX2Y(card)->dev->devnum
366 ); 365 );
367 *cardp = card; 366 *cardp = card;
368 return 0; 367 return 0;
@@ -432,8 +431,8 @@ static void snd_usX2Y_card_private_free(struct snd_card *card)
432 usb_free_urb(usX2Y(card)->In04urb); 431 usb_free_urb(usX2Y(card)->In04urb);
433 if (usX2Y(card)->us428ctls_sharedmem) 432 if (usX2Y(card)->us428ctls_sharedmem)
434 snd_free_pages(usX2Y(card)->us428ctls_sharedmem, sizeof(*usX2Y(card)->us428ctls_sharedmem)); 433 snd_free_pages(usX2Y(card)->us428ctls_sharedmem, sizeof(*usX2Y(card)->us428ctls_sharedmem));
435 if (usX2Y(card)->chip.index >= 0 && usX2Y(card)->chip.index < SNDRV_CARDS) 434 if (usX2Y(card)->card_index >= 0 && usX2Y(card)->card_index < SNDRV_CARDS)
436 snd_usX2Y_card_used[usX2Y(card)->chip.index] = 0; 435 snd_usX2Y_card_used[usX2Y(card)->card_index] = 0;
437} 436}
438 437
439/* 438/*
@@ -445,13 +444,12 @@ static void usX2Y_usb_disconnect(struct usb_device *device, void* ptr)
445 struct snd_card *card = ptr; 444 struct snd_card *card = ptr;
446 struct usX2Ydev *usX2Y = usX2Y(card); 445 struct usX2Ydev *usX2Y = usX2Y(card);
447 struct list_head *p; 446 struct list_head *p;
448 usX2Y->chip.shutdown = 1;
449 usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; 447 usX2Y->chip_status = USX2Y_STAT_CHIP_HUP;
450 usX2Y_unlinkSeq(&usX2Y->AS04); 448 usX2Y_unlinkSeq(&usX2Y->AS04);
451 usb_kill_urb(usX2Y->In04urb); 449 usb_kill_urb(usX2Y->In04urb);
452 snd_card_disconnect(card); 450 snd_card_disconnect(card);
453 /* release the midi resources */ 451 /* release the midi resources */
454 list_for_each(p, &usX2Y->chip.midi_list) { 452 list_for_each(p, &usX2Y->midi_list) {
455 snd_usbmidi_disconnect(p); 453 snd_usbmidi_disconnect(p);
456 } 454 }
457 if (usX2Y->us428ctls_sharedmem) 455 if (usX2Y->us428ctls_sharedmem)
diff --git a/sound/usb/usx2y/usbusx2y.h b/sound/usb/usx2y/usbusx2y.h
index 456b5fdbc339..1d174cea352b 100644
--- a/sound/usb/usx2y/usbusx2y.h
+++ b/sound/usb/usx2y/usbusx2y.h
@@ -22,7 +22,8 @@ struct snd_usX2Y_urbSeq {
22#include "usx2yhwdeppcm.h" 22#include "usx2yhwdeppcm.h"
23 23
24struct usX2Ydev { 24struct usX2Ydev {
25 struct snd_usb_audio chip; 25 struct usb_device *dev;
26 int card_index;
26 int stride; 27 int stride;
27 struct urb *In04urb; 28 struct urb *In04urb;
28 void *In04Buf; 29 void *In04Buf;
@@ -42,6 +43,9 @@ struct usX2Ydev {
42 struct snd_usX2Y_substream *subs[4]; 43 struct snd_usX2Y_substream *subs[4];
43 struct snd_usX2Y_substream * volatile prepare_subs; 44 struct snd_usX2Y_substream * volatile prepare_subs;
44 wait_queue_head_t prepare_wait_queue; 45 wait_queue_head_t prepare_wait_queue;
46 struct list_head midi_list;
47 struct list_head pcm_list;
48 int pcm_devs;
45}; 49};
46 50
47 51
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 9efd27f6b52f..74a67a85aa81 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -199,7 +199,7 @@ static int usX2Y_urb_submit(struct snd_usX2Y_substream *subs, struct urb *urb, i
199 return -ENODEV; 199 return -ENODEV;
200 urb->start_frame = (frame + NRURBS * nr_of_packs()); // let hcd do rollover sanity checks 200 urb->start_frame = (frame + NRURBS * nr_of_packs()); // let hcd do rollover sanity checks
201 urb->hcpriv = NULL; 201 urb->hcpriv = NULL;
202 urb->dev = subs->usX2Y->chip.dev; /* we need to set this at each time */ 202 urb->dev = subs->usX2Y->dev; /* we need to set this at each time */
203 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { 203 if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
204 snd_printk(KERN_ERR "usb_submit_urb() returned %i\n", err); 204 snd_printk(KERN_ERR "usb_submit_urb() returned %i\n", err);
205 return err; 205 return err;
@@ -300,7 +300,7 @@ static void usX2Y_error_sequence(struct usX2Ydev *usX2Y,
300"Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" 300"Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n"
301"Most propably some urb of usb-frame %i is still missing.\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"Cause could be too long delays in usb-hcd interrupt handling.\n",
303 usb_get_current_frame_number(usX2Y->chip.dev), 303 usb_get_current_frame_number(usX2Y->dev),
304 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", 304 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out",
305 usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); 305 usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame);
306 usX2Y_clients_stop(usX2Y); 306 usX2Y_clients_stop(usX2Y);
@@ -313,7 +313,7 @@ static void i_usX2Y_urb_complete(struct urb *urb)
313 313
314 if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { 314 if (unlikely(atomic_read(&subs->state) < state_PREPARED)) {
315 snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", 315 snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n",
316 usb_get_current_frame_number(usX2Y->chip.dev), 316 usb_get_current_frame_number(usX2Y->dev),
317 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", 317 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out",
318 urb->status, urb->start_frame); 318 urb->status, urb->start_frame);
319 return; 319 return;
@@ -424,7 +424,7 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs)
424 int i; 424 int i;
425 unsigned int pipe; 425 unsigned int pipe;
426 int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; 426 int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK];
427 struct usb_device *dev = subs->usX2Y->chip.dev; 427 struct usb_device *dev = subs->usX2Y->dev;
428 428
429 pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : 429 pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) :
430 usb_rcvisocpipe(dev, subs->endpoint); 430 usb_rcvisocpipe(dev, subs->endpoint);
@@ -500,7 +500,7 @@ static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs)
500 unsigned long pack; 500 unsigned long pack;
501 if (0 == i) 501 if (0 == i)
502 atomic_set(&subs->state, state_STARTING3); 502 atomic_set(&subs->state, state_STARTING3);
503 urb->dev = usX2Y->chip.dev; 503 urb->dev = usX2Y->dev;
504 urb->transfer_flags = URB_ISO_ASAP; 504 urb->transfer_flags = URB_ISO_ASAP;
505 for (pack = 0; pack < nr_of_packs(); pack++) { 505 for (pack = 0; pack < nr_of_packs(); pack++) {
506 urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack; 506 urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack;
@@ -692,7 +692,7 @@ static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate)
692 } 692 }
693 ((char*)(usbdata + i))[0] = ra[i].c1; 693 ((char*)(usbdata + i))[0] = ra[i].c1;
694 ((char*)(usbdata + i))[1] = ra[i].c2; 694 ((char*)(usbdata + i))[1] = ra[i].c2;
695 usb_fill_bulk_urb(us->urb[i], usX2Y->chip.dev, usb_sndbulkpipe(usX2Y->chip.dev, 4), 695 usb_fill_bulk_urb(us->urb[i], usX2Y->dev, usb_sndbulkpipe(usX2Y->dev, 4),
696 usbdata + i, 2, i_usX2Y_04Int, usX2Y); 696 usbdata + i, 2, i_usX2Y_04Int, usX2Y);
697#ifdef OLD_USB 697#ifdef OLD_USB
698 us->urb[i]->transfer_flags = USB_QUEUE_BULK; 698 us->urb[i]->transfer_flags = USB_QUEUE_BULK;
@@ -740,17 +740,17 @@ static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format)
740 alternate = 1; 740 alternate = 1;
741 usX2Y->stride = 4; 741 usX2Y->stride = 4;
742 } 742 }
743 list_for_each(p, &usX2Y->chip.midi_list) { 743 list_for_each(p, &usX2Y->midi_list) {
744 snd_usbmidi_input_stop(p); 744 snd_usbmidi_input_stop(p);
745 } 745 }
746 usb_kill_urb(usX2Y->In04urb); 746 usb_kill_urb(usX2Y->In04urb);
747 if ((err = usb_set_interface(usX2Y->chip.dev, 0, alternate))) { 747 if ((err = usb_set_interface(usX2Y->dev, 0, alternate))) {
748 snd_printk(KERN_ERR "usb_set_interface error \n"); 748 snd_printk(KERN_ERR "usb_set_interface error \n");
749 return err; 749 return err;
750 } 750 }
751 usX2Y->In04urb->dev = usX2Y->chip.dev; 751 usX2Y->In04urb->dev = usX2Y->dev;
752 err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); 752 err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL);
753 list_for_each(p, &usX2Y->chip.midi_list) { 753 list_for_each(p, &usX2Y->midi_list) {
754 snd_usbmidi_input_start(p); 754 snd_usbmidi_input_start(p);
755 } 755 }
756 usX2Y->format = format; 756 usX2Y->format = format;
@@ -955,7 +955,7 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint,
955 struct snd_pcm *pcm; 955 struct snd_pcm *pcm;
956 int err, i; 956 int err, i;
957 struct snd_usX2Y_substream **usX2Y_substream = 957 struct snd_usX2Y_substream **usX2Y_substream =
958 usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs; 958 usX2Y(card)->subs + 2 * usX2Y(card)->pcm_devs;
959 959
960 for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; 960 for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE;
961 i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { 961 i <= SNDRV_PCM_STREAM_CAPTURE; ++i) {
@@ -971,7 +971,7 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint,
971 usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]->endpoint = playback_endpoint; 971 usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]->endpoint = playback_endpoint;
972 usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]->endpoint = capture_endpoint; 972 usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]->endpoint = capture_endpoint;
973 973
974 err = snd_pcm_new(card, NAME_ALLCAPS" Audio", usX2Y(card)->chip.pcm_devs, 974 err = snd_pcm_new(card, NAME_ALLCAPS" Audio", usX2Y(card)->pcm_devs,
975 playback_endpoint ? 1 : 0, 1, 975 playback_endpoint ? 1 : 0, 1,
976 &pcm); 976 &pcm);
977 if (err < 0) { 977 if (err < 0) {
@@ -987,7 +987,7 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint,
987 pcm->private_free = snd_usX2Y_pcm_private_free; 987 pcm->private_free = snd_usX2Y_pcm_private_free;
988 pcm->info_flags = 0; 988 pcm->info_flags = 0;
989 989
990 sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->chip.pcm_devs); 990 sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs);
991 991
992 if ((playback_endpoint && 992 if ((playback_endpoint &&
993 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, 993 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
@@ -1001,7 +1001,7 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint,
1001 snd_usX2Y_pcm_private_free(pcm); 1001 snd_usX2Y_pcm_private_free(pcm);
1002 return err; 1002 return err;
1003 } 1003 }
1004 usX2Y(card)->chip.pcm_devs++; 1004 usX2Y(card)->pcm_devs++;
1005 1005
1006 return 0; 1006 return 0;
1007} 1007}
@@ -1013,14 +1013,14 @@ int usX2Y_audio_create(struct snd_card *card)
1013{ 1013{
1014 int err = 0; 1014 int err = 0;
1015 1015
1016 INIT_LIST_HEAD(&usX2Y(card)->chip.pcm_list); 1016 INIT_LIST_HEAD(&usX2Y(card)->pcm_list);
1017 1017
1018 if (0 > (err = usX2Y_audio_stream_new(card, 0xA, 0x8))) 1018 if (0 > (err = usX2Y_audio_stream_new(card, 0xA, 0x8)))
1019 return err; 1019 return err;
1020 if (le16_to_cpu(usX2Y(card)->chip.dev->descriptor.idProduct) == USB_ID_US428) 1020 if (le16_to_cpu(usX2Y(card)->dev->descriptor.idProduct) == USB_ID_US428)
1021 if (0 > (err = usX2Y_audio_stream_new(card, 0, 0xA))) 1021 if (0 > (err = usX2Y_audio_stream_new(card, 0, 0xA)))
1022 return err; 1022 return err;
1023 if (le16_to_cpu(usX2Y(card)->chip.dev->descriptor.idProduct) != USB_ID_US122) 1023 if (le16_to_cpu(usX2Y(card)->dev->descriptor.idProduct) != USB_ID_US122)
1024 err = usX2Y_rate_set(usX2Y(card), 44100); // Lets us428 recognize output-volume settings, disturbs us122. 1024 err = usX2Y_rate_set(usX2Y(card), 44100); // Lets us428 recognize output-volume settings, disturbs us122.
1025 return err; 1025 return err;
1026} 1026}
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c
index 4b2304c2e02d..9ed6c3956ca7 100644
--- a/sound/usb/usx2y/usx2yhwdeppcm.c
+++ b/sound/usb/usx2y/usx2yhwdeppcm.c
@@ -234,7 +234,7 @@ static void i_usX2Y_usbpcm_urb_complete(struct urb *urb)
234 234
235 if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { 235 if (unlikely(atomic_read(&subs->state) < state_PREPARED)) {
236 snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", 236 snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n",
237 usb_get_current_frame_number(usX2Y->chip.dev), 237 usb_get_current_frame_number(usX2Y->dev),
238 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", 238 subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out",
239 urb->status, urb->start_frame); 239 urb->status, urb->start_frame);
240 return; 240 return;
@@ -318,7 +318,7 @@ static int usX2Y_usbpcm_urbs_allocate(struct snd_usX2Y_substream *subs)
318 int i; 318 int i;
319 unsigned int pipe; 319 unsigned int pipe;
320 int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; 320 int is_playback = subs == subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK];
321 struct usb_device *dev = subs->usX2Y->chip.dev; 321 struct usb_device *dev = subs->usX2Y->dev;
322 322
323 pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) : 323 pipe = is_playback ? usb_sndisocpipe(dev, subs->endpoint) :
324 usb_rcvisocpipe(dev, subs->endpoint); 324 usb_rcvisocpipe(dev, subs->endpoint);
@@ -441,7 +441,7 @@ static int usX2Y_usbpcm_urbs_start(struct snd_usX2Y_substream *subs)
441 unsigned long pack; 441 unsigned long pack;
442 if (0 == u) 442 if (0 == u)
443 atomic_set(&subs->state, state_STARTING3); 443 atomic_set(&subs->state, state_STARTING3);
444 urb->dev = usX2Y->chip.dev; 444 urb->dev = usX2Y->dev;
445 urb->transfer_flags = URB_ISO_ASAP; 445 urb->transfer_flags = URB_ISO_ASAP;
446 for (pack = 0; pack < nr_of_packs(); pack++) { 446 for (pack = 0; pack < nr_of_packs(); pack++) {
447 urb->iso_frame_desc[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs()); 447 urb->iso_frame_desc[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs());
@@ -741,7 +741,7 @@ int usX2Y_hwdep_pcm_new(struct snd_card *card)
741 int err; 741 int err;
742 struct snd_hwdep *hw; 742 struct snd_hwdep *hw;
743 struct snd_pcm *pcm; 743 struct snd_pcm *pcm;
744 struct usb_device *dev = usX2Y(card)->chip.dev; 744 struct usb_device *dev = usX2Y(card)->dev;
745 if (1 != nr_of_packs()) 745 if (1 != nr_of_packs())
746 return 0; 746 return 0;
747 747