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>
This commit is contained in:
zain wang 2017-11-27 17:09:14 +08:00 committed by Sugar Zhang
parent c2fc451481
commit a6ddb2896a

View File

@ -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;