Commit d82af9f9 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Takashi Iwai

sound: usb: make the USB MIDI module more independent

Remove the dependecy from the USB MIDI code on the snd_usb_audio
structure.  This allows using the USB MIDI module from another driver
without having to pretend to be the generic USB audio driver.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 96f61d9a
...@@ -2893,7 +2893,9 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) ...@@ -2893,7 +2893,9 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || if ((altsd->bInterfaceClass == USB_CLASS_AUDIO ||
altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) &&
altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) { altsd->bInterfaceSubClass == USB_SUBCLASS_MIDI_STREAMING) {
if (snd_usb_create_midi_interface(chip, iface, NULL) < 0) { int err = snd_usbmidi_create(chip->card, iface,
&chip->midi_list, NULL);
if (err < 0) {
snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j); snd_printk(KERN_ERR "%d:%u:%d: cannot create sequencer device\n", dev->devnum, ctrlif, j);
continue; continue;
} }
...@@ -3038,12 +3040,11 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, ...@@ -3038,12 +3040,11 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
.type = QUIRK_MIDI_FIXED_ENDPOINT, .type = QUIRK_MIDI_FIXED_ENDPOINT,
.data = &uaxx_ep .data = &uaxx_ep
}; };
if (chip->usb_id == USB_ID(0x0582, 0x002b)) const struct snd_usb_audio_quirk *quirk =
return snd_usb_create_midi_interface(chip, iface, chip->usb_id == USB_ID(0x0582, 0x002b)
&ua700_quirk); ? &ua700_quirk : &uaxx_quirk;
else return snd_usbmidi_create(chip->card, iface,
return snd_usb_create_midi_interface(chip, iface, &chip->midi_list, quirk);
&uaxx_quirk);
} }
if (altsd->bNumEndpoints != 1) if (altsd->bNumEndpoints != 1)
...@@ -3370,6 +3371,13 @@ static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, ...@@ -3370,6 +3371,13 @@ static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
return 0; /* keep this altsetting */ return 0; /* keep this altsetting */
} }
static int create_any_midi_quirk(struct snd_usb_audio *chip,
struct usb_interface *intf,
const struct snd_usb_audio_quirk *quirk)
{
return snd_usbmidi_create(chip->card, intf, &chip->midi_list, quirk);
}
/* /*
* audio-interface quirks * audio-interface quirks
* *
...@@ -3387,14 +3395,14 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip, ...@@ -3387,14 +3395,14 @@ static int snd_usb_create_quirk(struct snd_usb_audio *chip,
static const quirk_func_t quirk_funcs[] = { static const quirk_func_t quirk_funcs[] = {
[QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk, [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk,
[QUIRK_COMPOSITE] = create_composite_quirk, [QUIRK_COMPOSITE] = create_composite_quirk,
[QUIRK_MIDI_STANDARD_INTERFACE] = snd_usb_create_midi_interface, [QUIRK_MIDI_STANDARD_INTERFACE] = create_any_midi_quirk,
[QUIRK_MIDI_FIXED_ENDPOINT] = snd_usb_create_midi_interface, [QUIRK_MIDI_FIXED_ENDPOINT] = create_any_midi_quirk,
[QUIRK_MIDI_YAMAHA] = snd_usb_create_midi_interface, [QUIRK_MIDI_YAMAHA] = create_any_midi_quirk,
[QUIRK_MIDI_MIDIMAN] = snd_usb_create_midi_interface, [QUIRK_MIDI_MIDIMAN] = create_any_midi_quirk,
[QUIRK_MIDI_NOVATION] = snd_usb_create_midi_interface, [QUIRK_MIDI_NOVATION] = create_any_midi_quirk,
[QUIRK_MIDI_FASTLANE] = snd_usb_create_midi_interface, [QUIRK_MIDI_FASTLANE] = create_any_midi_quirk,
[QUIRK_MIDI_EMAGIC] = snd_usb_create_midi_interface, [QUIRK_MIDI_EMAGIC] = create_any_midi_quirk,
[QUIRK_MIDI_CME] = snd_usb_create_midi_interface, [QUIRK_MIDI_CME] = create_any_midi_quirk,
[QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk, [QUIRK_AUDIO_STANDARD_INTERFACE] = create_standard_audio_quirk,
[QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk, [QUIRK_AUDIO_FIXED_ENDPOINT] = create_fixed_stream_quirk,
[QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk, [QUIRK_AUDIO_EDIROL_UA1000] = create_ua1000_quirk,
......
...@@ -132,7 +132,6 @@ struct snd_usb_audio { ...@@ -132,7 +132,6 @@ struct snd_usb_audio {
int pcm_devs; int pcm_devs;
struct list_head midi_list; /* list of midi interfaces */ struct list_head midi_list; /* list of midi interfaces */
int next_midi_device;
struct list_head mixer_list; /* list of mixer interfaces */ struct list_head mixer_list; /* list of mixer interfaces */
}; };
...@@ -227,8 +226,10 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, ...@@ -227,8 +226,10 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
int ignore_error); int ignore_error);
void snd_usb_mixer_disconnect(struct list_head *p); void snd_usb_mixer_disconnect(struct list_head *p);
int snd_usb_create_midi_interface(struct snd_usb_audio *chip, struct usb_interface *iface, int snd_usbmidi_create(struct snd_card *card,
const struct snd_usb_audio_quirk *quirk); struct usb_interface *iface,
struct list_head *midi_list,
const struct snd_usb_audio_quirk *quirk);
void snd_usbmidi_input_stop(struct list_head* p); void snd_usbmidi_input_stop(struct list_head* p);
void snd_usbmidi_input_start(struct list_head* p); void snd_usbmidi_input_start(struct list_head* p);
void snd_usbmidi_disconnect(struct list_head *p); void snd_usbmidi_disconnect(struct list_head *p);
......
This diff is collapsed.
...@@ -62,8 +62,8 @@ static int us122l_create_usbmidi(struct snd_card *card) ...@@ -62,8 +62,8 @@ static int us122l_create_usbmidi(struct snd_card *card)
struct usb_device *dev = US122L(card)->chip.dev; struct usb_device *dev = US122L(card)->chip.dev;
struct usb_interface *iface = usb_ifnum_to_if(dev, 1); struct usb_interface *iface = usb_ifnum_to_if(dev, 1);
return snd_usb_create_midi_interface(&US122L(card)->chip, return snd_usbmidi_create(card, iface,
iface, &quirk); &US122L(card)->midi_list, &quirk);
} }
static int us144_create_usbmidi(struct snd_card *card) static int us144_create_usbmidi(struct snd_card *card)
...@@ -84,8 +84,8 @@ static int us144_create_usbmidi(struct snd_card *card) ...@@ -84,8 +84,8 @@ static int us144_create_usbmidi(struct snd_card *card)
struct usb_device *dev = US122L(card)->chip.dev; struct usb_device *dev = US122L(card)->chip.dev;
struct usb_interface *iface = usb_ifnum_to_if(dev, 0); struct usb_interface *iface = usb_ifnum_to_if(dev, 0);
return snd_usb_create_midi_interface(&US122L(card)->chip, return snd_usbmidi_create(card, iface,
iface, &quirk); &US122L(card)->midi_list, &quirk);
} }
/* /*
...@@ -297,7 +297,7 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw, ...@@ -297,7 +297,7 @@ static unsigned int usb_stream_hwdep_poll(struct snd_hwdep *hw,
static void us122l_stop(struct us122l *us122l) static void us122l_stop(struct us122l *us122l)
{ {
struct list_head *p; struct list_head *p;
list_for_each(p, &us122l->chip.midi_list) list_for_each(p, &us122l->midi_list)
snd_usbmidi_input_stop(p); snd_usbmidi_input_stop(p);
usb_stream_stop(&us122l->sk); usb_stream_stop(&us122l->sk);
...@@ -363,7 +363,7 @@ static bool us122l_start(struct us122l *us122l, ...@@ -363,7 +363,7 @@ static bool us122l_start(struct us122l *us122l,
snd_printk(KERN_ERR "us122l_start error %i \n", err); snd_printk(KERN_ERR "us122l_start error %i \n", err);
goto out; goto out;
} }
list_for_each(p, &us122l->chip.midi_list) list_for_each(p, &us122l->midi_list)
snd_usbmidi_input_start(p); snd_usbmidi_input_start(p);
success = true; success = true;
out: out:
...@@ -508,7 +508,7 @@ static bool us122l_create_card(struct snd_card *card) ...@@ -508,7 +508,7 @@ static bool us122l_create_card(struct snd_card *card)
if (err < 0) { if (err < 0) {
/* release the midi resources */ /* release the midi resources */
struct list_head *p; struct list_head *p;
list_for_each(p, &us122l->chip.midi_list) list_for_each(p, &us122l->midi_list)
snd_usbmidi_disconnect(p); snd_usbmidi_disconnect(p);
us122l_stop(us122l); us122l_stop(us122l);
...@@ -546,7 +546,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp) ...@@ -546,7 +546,7 @@ static int usx2y_create_card(struct usb_device *device, struct snd_card **cardp)
US122L(card)->chip.card = card; US122L(card)->chip.card = card;
mutex_init(&US122L(card)->mutex); mutex_init(&US122L(card)->mutex);
init_waitqueue_head(&US122L(card)->sk.sleep); init_waitqueue_head(&US122L(card)->sk.sleep);
INIT_LIST_HEAD(&US122L(card)->chip.midi_list); INIT_LIST_HEAD(&US122L(card)->midi_list);
strcpy(card->driver, "USB "NAME_ALLCAPS""); strcpy(card->driver, "USB "NAME_ALLCAPS"");
sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)",
...@@ -638,7 +638,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf) ...@@ -638,7 +638,7 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
us122l->chip.shutdown = 1; us122l->chip.shutdown = 1;
/* release the midi resources */ /* release the midi resources */
list_for_each(p, &us122l->chip.midi_list) { list_for_each(p, &us122l->midi_list) {
snd_usbmidi_disconnect(p); snd_usbmidi_disconnect(p);
} }
...@@ -667,7 +667,7 @@ static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -667,7 +667,7 @@ static int snd_us122l_suspend(struct usb_interface *intf, pm_message_t message)
if (!us122l) if (!us122l)
return 0; return 0;
list_for_each(p, &us122l->chip.midi_list) list_for_each(p, &us122l->midi_list)
snd_usbmidi_input_stop(p); snd_usbmidi_input_stop(p);
mutex_lock(&us122l->mutex); mutex_lock(&us122l->mutex);
...@@ -720,7 +720,7 @@ static int snd_us122l_resume(struct usb_interface *intf) ...@@ -720,7 +720,7 @@ static int snd_us122l_resume(struct usb_interface *intf)
if (err) if (err)
goto unlock; goto unlock;
list_for_each(p, &us122l->chip.midi_list) list_for_each(p, &us122l->midi_list)
snd_usbmidi_input_start(p); snd_usbmidi_input_start(p);
unlock: unlock:
mutex_unlock(&us122l->mutex); mutex_unlock(&us122l->mutex);
......
...@@ -12,6 +12,7 @@ struct us122l { ...@@ -12,6 +12,7 @@ struct us122l {
unsigned second_periods_polled; unsigned second_periods_polled;
struct file *master; struct file *master;
struct file *slave; struct file *slave;
struct list_head midi_list;
atomic_t mmap_count; atomic_t mmap_count;
}; };
......
...@@ -171,7 +171,7 @@ static int usX2Y_create_usbmidi(struct snd_card *card) ...@@ -171,7 +171,7 @@ static int usX2Y_create_usbmidi(struct snd_card *card)
&quirk_2 : &quirk_1; &quirk_2 : &quirk_1;
snd_printdd("usX2Y_create_usbmidi \n"); snd_printdd("usX2Y_create_usbmidi \n");
return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); return snd_usbmidi_create(card, iface, &usX2Y(card)->midi_list, quirk);
} }
static int usX2Y_create_alsa_devices(struct snd_card *card) static int usX2Y_create_alsa_devices(struct snd_card *card)
......
...@@ -354,7 +354,7 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp) ...@@ -354,7 +354,7 @@ static int usX2Y_create_card(struct usb_device *device, struct snd_card **cardp)
usX2Y(card)->chip.card = card; usX2Y(card)->chip.card = card;
init_waitqueue_head(&usX2Y(card)->prepare_wait_queue); init_waitqueue_head(&usX2Y(card)->prepare_wait_queue);
mutex_init(&usX2Y(card)->prepare_mutex); mutex_init(&usX2Y(card)->prepare_mutex);
INIT_LIST_HEAD(&usX2Y(card)->chip.midi_list); INIT_LIST_HEAD(&usX2Y(card)->midi_list);
strcpy(card->driver, "USB "NAME_ALLCAPS""); strcpy(card->driver, "USB "NAME_ALLCAPS"");
sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); sprintf(card->shortname, "TASCAM "NAME_ALLCAPS"");
sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)",
...@@ -451,7 +451,7 @@ static void usX2Y_usb_disconnect(struct usb_device *device, void* ptr) ...@@ -451,7 +451,7 @@ static void usX2Y_usb_disconnect(struct usb_device *device, void* ptr)
usb_kill_urb(usX2Y->In04urb); usb_kill_urb(usX2Y->In04urb);
snd_card_disconnect(card); snd_card_disconnect(card);
/* release the midi resources */ /* release the midi resources */
list_for_each(p, &usX2Y->chip.midi_list) { list_for_each(p, &usX2Y->midi_list) {
snd_usbmidi_disconnect(p); snd_usbmidi_disconnect(p);
} }
if (usX2Y->us428ctls_sharedmem) if (usX2Y->us428ctls_sharedmem)
......
...@@ -42,6 +42,7 @@ struct usX2Ydev { ...@@ -42,6 +42,7 @@ struct usX2Ydev {
struct snd_usX2Y_substream *subs[4]; struct snd_usX2Y_substream *subs[4];
struct snd_usX2Y_substream * volatile prepare_subs; struct snd_usX2Y_substream * volatile prepare_subs;
wait_queue_head_t prepare_wait_queue; wait_queue_head_t prepare_wait_queue;
struct list_head midi_list;
}; };
......
...@@ -740,7 +740,7 @@ static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format) ...@@ -740,7 +740,7 @@ static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format)
alternate = 1; alternate = 1;
usX2Y->stride = 4; usX2Y->stride = 4;
} }
list_for_each(p, &usX2Y->chip.midi_list) { list_for_each(p, &usX2Y->midi_list) {
snd_usbmidi_input_stop(p); snd_usbmidi_input_stop(p);
} }
usb_kill_urb(usX2Y->In04urb); usb_kill_urb(usX2Y->In04urb);
...@@ -750,7 +750,7 @@ static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format) ...@@ -750,7 +750,7 @@ static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format)
} }
usX2Y->In04urb->dev = usX2Y->chip.dev; usX2Y->In04urb->dev = usX2Y->chip.dev;
err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL);
list_for_each(p, &usX2Y->chip.midi_list) { list_for_each(p, &usX2Y->midi_list) {
snd_usbmidi_input_start(p); snd_usbmidi_input_start(p);
} }
usX2Y->format = format; usX2Y->format = format;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment