diff options
author | zain wang <wzz@rock-chips.com> | 2017-11-27 17:09:14 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2017-11-28 17:32:12 +0800 |
commit | a42f179e652187e1a44c5f45103e2b76be6afff5 (patch) | |
tree | 1fdb6a29336321399b9eaa6558f94654082ab81f /sound | |
parent | 34fec927923f986e72c2856bfa0eafc9a96ecb3a (diff) |
ALSA: usb-audio: Add SNDRV_PCM_TRIGGER_SUSPEND/RESUME to trigger functions
Missing SNDRV_PCM_TRIGGER_SUSPEND/RESUME, usb-audio can not enter suspend
since pcm was always running.
Change-Id: I0f7be7345f2b5c1bd42dad4c6fc4647c8636eed8
Signed-off-by: zain wang <wzz@rock-chips.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/usb/pcm.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 48afae053c56..9d36437bb6e8 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -272,15 +272,16 @@ static int start_endpoints(struct snd_usb_substream *subs) static void stop_endpoints(struct snd_usb_substream *subs, bool wait) { - if (test_and_clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) + if (test_and_clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) { snd_usb_endpoint_stop(subs->sync_endpoint); + if (wait) + snd_usb_endpoint_sync_pending_stop(subs->sync_endpoint); + } - if (test_and_clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags)) + if (test_and_clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags)) { snd_usb_endpoint_stop(subs->data_endpoint); - - if (wait) { - snd_usb_endpoint_sync_pending_stop(subs->sync_endpoint); - snd_usb_endpoint_sync_pending_stop(subs->data_endpoint); + if (wait) + snd_usb_endpoint_sync_pending_stop(subs->data_endpoint); } } @@ -1626,12 +1627,17 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: subs->trigger_tstamp_pending_update = true; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: subs->data_endpoint->prepare_data_urb = prepare_playback_urb; subs->data_endpoint->retire_data_urb = retire_playback_urb; subs->running = 1; return 0; + case SNDRV_PCM_TRIGGER_SUSPEND: + stop_endpoints(subs, true); + subs->running = 0; + return 0; case SNDRV_PCM_TRIGGER_STOP: stop_endpoints(subs, false); subs->running = 0; @@ -1655,6 +1661,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: err = start_endpoints(subs); if (err < 0) return err; @@ -1662,6 +1669,10 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream subs->data_endpoint->retire_data_urb = retire_capture_urb; subs->running = 1; return 0; + case SNDRV_PCM_TRIGGER_SUSPEND: + stop_endpoints(subs, true); + subs->running = 0; + return 0; case SNDRV_PCM_TRIGGER_STOP: stop_endpoints(subs, false); subs->running = 0; |