diff options
author | Adam Goode <agoode@google.com> | 2014-08-05 12:44:50 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-08-05 14:08:00 -0400 |
commit | f7881e5e8ef305e62084bf3d31b5b0d827fdf511 (patch) | |
tree | 8b9c547475e928678582f6892286310f3a53abe0 /sound/usb | |
parent | 81cb6b6be54d160ac8feb61f1510f33a3cece1d3 (diff) |
ALSA: usb-audio: Respond to suspend and resume callbacks for MIDI input
sound/usb/card.c registers USB suspend and resume but did not previously
kill the input URBs. This means that USB MIDI devices left open across
suspend/resume had non-functional input (output still usually worked,
but it looks like that is another issue). Before this change, we would
get ESHUTDOWN for each of the input URBs at suspend time, killing input.
Signed-off-by: Adam Goode <agoode@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/card.c | 9 | ||||
-rw-r--r-- | sound/usb/midi.c | 28 | ||||
-rw-r--r-- | sound/usb/midi.h | 2 |
3 files changed, 39 insertions, 0 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c index a09e5f3519e3..7ecd0e8a5c51 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c | |||
@@ -680,6 +680,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) | |||
680 | struct snd_usb_audio *chip = usb_get_intfdata(intf); | 680 | struct snd_usb_audio *chip = usb_get_intfdata(intf); |
681 | struct snd_usb_stream *as; | 681 | struct snd_usb_stream *as; |
682 | struct usb_mixer_interface *mixer; | 682 | struct usb_mixer_interface *mixer; |
683 | struct list_head *p; | ||
683 | 684 | ||
684 | if (chip == (void *)-1L) | 685 | if (chip == (void *)-1L) |
685 | return 0; | 686 | return 0; |
@@ -692,6 +693,9 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) | |||
692 | as->substream[0].need_setup_ep = | 693 | as->substream[0].need_setup_ep = |
693 | as->substream[1].need_setup_ep = true; | 694 | as->substream[1].need_setup_ep = true; |
694 | } | 695 | } |
696 | list_for_each(p, &chip->midi_list) { | ||
697 | snd_usbmidi_suspend(p); | ||
698 | } | ||
695 | } | 699 | } |
696 | } else { | 700 | } else { |
697 | /* | 701 | /* |
@@ -713,6 +717,7 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume) | |||
713 | { | 717 | { |
714 | struct snd_usb_audio *chip = usb_get_intfdata(intf); | 718 | struct snd_usb_audio *chip = usb_get_intfdata(intf); |
715 | struct usb_mixer_interface *mixer; | 719 | struct usb_mixer_interface *mixer; |
720 | struct list_head *p; | ||
716 | int err = 0; | 721 | int err = 0; |
717 | 722 | ||
718 | if (chip == (void *)-1L) | 723 | if (chip == (void *)-1L) |
@@ -731,6 +736,10 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume) | |||
731 | goto err_out; | 736 | goto err_out; |
732 | } | 737 | } |
733 | 738 | ||
739 | list_for_each(p, &chip->midi_list) { | ||
740 | snd_usbmidi_resume(p); | ||
741 | } | ||
742 | |||
734 | if (!chip->autosuspended) | 743 | if (!chip->autosuspended) |
735 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); | 744 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); |
736 | chip->autosuspended = 0; | 745 | chip->autosuspended = 0; |
diff --git a/sound/usb/midi.c b/sound/usb/midi.c index 9da74d2e8eee..9a4e82cf4ef9 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c | |||
@@ -2187,6 +2187,34 @@ void snd_usbmidi_input_start(struct list_head* p) | |||
2187 | EXPORT_SYMBOL(snd_usbmidi_input_start); | 2187 | EXPORT_SYMBOL(snd_usbmidi_input_start); |
2188 | 2188 | ||
2189 | /* | 2189 | /* |
2190 | * Prepare for suspend. Typically called from the USB suspend callback. | ||
2191 | */ | ||
2192 | void snd_usbmidi_suspend(struct list_head *p) | ||
2193 | { | ||
2194 | struct snd_usb_midi *umidi; | ||
2195 | |||
2196 | umidi = list_entry(p, struct snd_usb_midi, list); | ||
2197 | mutex_lock(&umidi->mutex); | ||
2198 | snd_usbmidi_input_stop(p); | ||
2199 | mutex_unlock(&umidi->mutex); | ||
2200 | } | ||
2201 | EXPORT_SYMBOL(snd_usbmidi_suspend); | ||
2202 | |||
2203 | /* | ||
2204 | * Resume. Typically called from the USB resume callback. | ||
2205 | */ | ||
2206 | void snd_usbmidi_resume(struct list_head *p) | ||
2207 | { | ||
2208 | struct snd_usb_midi *umidi; | ||
2209 | |||
2210 | umidi = list_entry(p, struct snd_usb_midi, list); | ||
2211 | mutex_lock(&umidi->mutex); | ||
2212 | snd_usbmidi_input_start(p); | ||
2213 | mutex_unlock(&umidi->mutex); | ||
2214 | } | ||
2215 | EXPORT_SYMBOL(snd_usbmidi_resume); | ||
2216 | |||
2217 | /* | ||
2190 | * Creates and registers everything needed for a MIDI streaming interface. | 2218 | * Creates and registers everything needed for a MIDI streaming interface. |
2191 | */ | 2219 | */ |
2192 | int snd_usbmidi_create(struct snd_card *card, | 2220 | int snd_usbmidi_create(struct snd_card *card, |
diff --git a/sound/usb/midi.h b/sound/usb/midi.h index 2fca80b744c0..46e5b65e81e7 100644 --- a/sound/usb/midi.h +++ b/sound/usb/midi.h | |||
@@ -46,5 +46,7 @@ int snd_usbmidi_create(struct snd_card *card, | |||
46 | void snd_usbmidi_input_stop(struct list_head* p); | 46 | void snd_usbmidi_input_stop(struct list_head* p); |
47 | void snd_usbmidi_input_start(struct list_head* p); | 47 | void snd_usbmidi_input_start(struct list_head* p); |
48 | void snd_usbmidi_disconnect(struct list_head *p); | 48 | void snd_usbmidi_disconnect(struct list_head *p); |
49 | void snd_usbmidi_suspend(struct list_head *p); | ||
50 | void snd_usbmidi_resume(struct list_head *p); | ||
49 | 51 | ||
50 | #endif /* __USBMIDI_H */ | 52 | #endif /* __USBMIDI_H */ |