From: Adam Goode <agoode@google.com>
To: patch@alsa-project.org
Cc: Adam Goode <agoode@google.com>, alsa-devel@alsa-project.org
Subject: [PATCH - sound/usb 1/1] Respond to suspend and resume callbacks for input in sound/usb/midi.c
Date: Tue, 5 Aug 2014 08:20:30 -0400 [thread overview]
Message-ID: <1407241230-486-1-git-send-email-agoode@google.com> (raw)
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>
diff --git a/sound/usb/card.c b/sound/usb/card.c
index a09e5f3..7ecd0e8 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)
struct snd_usb_audio *chip = usb_get_intfdata(intf);
struct snd_usb_stream *as;
struct usb_mixer_interface *mixer;
+ struct list_head *p;
if (chip == (void *)-1L)
return 0;
@@ -692,6 +693,9 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
as->substream[0].need_setup_ep =
as->substream[1].need_setup_ep = true;
}
+ list_for_each(p, &chip->midi_list) {
+ snd_usbmidi_suspend(p);
+ }
}
} else {
/*
@@ -713,6 +717,7 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
{
struct snd_usb_audio *chip = usb_get_intfdata(intf);
struct usb_mixer_interface *mixer;
+ struct list_head *p;
int err = 0;
if (chip == (void *)-1L)
@@ -731,6 +736,10 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
goto err_out;
}
+ list_for_each(p, &chip->midi_list) {
+ snd_usbmidi_resume(p);
+ }
+
if (!chip->autosuspended)
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
chip->autosuspended = 0;
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 9da74d2..e7c6c9d 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -2187,6 +2187,34 @@ void snd_usbmidi_input_start(struct list_head* p)
EXPORT_SYMBOL(snd_usbmidi_input_start);
/*
+ * Prepare for suspend. Typically called from the USB suspend callback.
+ */
+void snd_usbmidi_suspend(struct list_head* p)
+{
+ struct snd_usb_midi* umidi;
+
+ umidi = list_entry(p, struct snd_usb_midi, list);
+ mutex_lock(&umidi->mutex);
+ snd_usbmidi_input_stop(p);
+ mutex_unlock(&umidi->mutex);
+}
+EXPORT_SYMBOL(snd_usbmidi_suspend);
+
+/*
+ * Resume. Typically called from the USB resume callback.
+ */
+void snd_usbmidi_resume(struct list_head* p)
+{
+ struct snd_usb_midi* umidi;
+
+ umidi = list_entry(p, struct snd_usb_midi, list);
+ mutex_lock(&umidi->mutex);
+ snd_usbmidi_input_start(p);
+ mutex_unlock(&umidi->mutex);
+}
+EXPORT_SYMBOL(snd_usbmidi_resume);
+
+/*
* Creates and registers everything needed for a MIDI streaming interface.
*/
int snd_usbmidi_create(struct snd_card *card,
diff --git a/sound/usb/midi.h b/sound/usb/midi.h
index 2fca80b..46e5b65 100644
--- a/sound/usb/midi.h
+++ b/sound/usb/midi.h
@@ -46,5 +46,7 @@ int snd_usbmidi_create(struct snd_card *card,
void snd_usbmidi_input_stop(struct list_head* p);
void snd_usbmidi_input_start(struct list_head* p);
void snd_usbmidi_disconnect(struct list_head *p);
+void snd_usbmidi_suspend(struct list_head *p);
+void snd_usbmidi_resume(struct list_head *p);
#endif /* __USBMIDI_H */
--
2.0.0.526.g5318336
next reply other threads:[~2014-08-05 12:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-05 12:20 Adam Goode [this message]
2014-08-05 12:36 ` [PATCH - sound/usb 1/1] Respond to suspend and resume callbacks for input in sound/usb/midi.c Takashi Iwai
2014-08-05 16:44 ` [PATCH v2 - sound/usb 0/2] Respond to suspend and resume callbacks for usb midi Adam Goode
2014-08-05 16:44 ` [PATCH v2 - sound/usb 1/2] Respond to suspend and resume callbacks for MIDI input in sound/usb Adam Goode
2014-08-05 16:44 ` [PATCH v2 - sound/usb 2/2] Whitespace cleanups for sound/usb/midi.* Adam Goode
2014-08-05 18:09 ` [PATCH v2 - sound/usb 0/2] Respond to suspend and resume callbacks for usb midi Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407241230-486-1-git-send-email-agoode@google.com \
--to=agoode@google.com \
--cc=alsa-devel@alsa-project.org \
--cc=patch@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).