From a6ddb2896a924751e39ce6266cc2278217681f2e Mon Sep 17 00:00:00 2001 From: zain wang Date: Mon, 27 Nov 2017 17:09:14 +0800 Subject: [PATCH] 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 --- sound/usb/pcm.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 382847154227..7b6da099fe65 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -273,15 +273,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); } } @@ -1693,6 +1694,7 @@ 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; /* fall through */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: @@ -1700,6 +1702,10 @@ static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substrea 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; @@ -1723,6 +1729,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; @@ -1730,6 +1737,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;