diff options
author | Oliver Neukum <oneukum@suse.de> | 2011-03-11 14:51:12 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-03-11 14:59:29 +0100 |
commit | 88a8516a2128a6d078a106ead48092240e8a138f (patch) | |
tree | dc839c85a9b2fc2e17759c5a42368cb8300e42bc /sound/usb/midi.c | |
parent | edf7de31c25ce72f163bf7d1fc0d2711869d073c (diff) | |
download | op-kernel-dev-88a8516a2128a6d078a106ead48092240e8a138f.zip op-kernel-dev-88a8516a2128a6d078a106ead48092240e8a138f.tar.gz |
ALSA: usbaudio: implement USB autosuspend
Devices are autosuspended if no pcm nor midi channel is open
Mixer devices may be opened. This way they are active when
in use to play or record sound, but can be suspended while
users have a mixer application running.
[Small clean-ups using static inline by tiwai]
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/midi.c')
-rw-r--r-- | sound/usb/midi.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sound/usb/midi.c b/sound/usb/midi.c index db2dc5f..b4b39c0 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -54,6 +54,7 @@ #include <sound/asequencer.h> #include "usbaudio.h" #include "midi.h" +#include "power.h" #include "helper.h" /* @@ -1044,6 +1045,7 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) struct snd_usb_midi* umidi = substream->rmidi->private_data; struct usbmidi_out_port* port = NULL; int i, j; + int err; for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) if (umidi->endpoints[i].out) @@ -1056,6 +1058,9 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) snd_BUG(); return -ENXIO; } + err = usb_autopm_get_interface(umidi->iface); + if (err < 0) + return -EIO; substream->runtime->private_data = port; port->state = STATE_UNKNOWN; substream_open(substream, 1); @@ -1064,7 +1069,10 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) { + struct snd_usb_midi* umidi = substream->rmidi->private_data; + substream_open(substream, 0); + usb_autopm_put_interface(umidi->iface); return 0; } |