1 From e5414b543a330c64b2e0b5e96d604cf580c2b9b7 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Tue, 4 Sep 2018 17:58:38 +0200
4 Subject: [PATCH] staging: bcm2835-audio: Fix incorrect draining
7 commit 7d2a91f5f1bcf08ca257bcf1ed9721fcd341f834 upstream.
9 The handling of SNDRV_PCM_TRIGGER_STOP at the trigger callback is
10 incorrect: when the STOP is issued, the driver is supposed to drop the
11 stream immediately. Meanwhile bcm2835 driver checks the DRAINING
12 state and tries to issue some different command.
14 This patch straightens things a bit, dropping the incorrect state
15 checks. The draining behavior would be still not perfect at this
16 point, but will be improved in a later patch.
18 Signed-off-by: Takashi Iwai <tiwai@suse.de>
19 Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 18 ++++++------------
23 1 file changed, 6 insertions(+), 12 deletions(-)
25 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
26 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
27 @@ -153,7 +153,6 @@ static int snd_bcm2835_playback_open_gen
28 chip->alsa_stream[idx] = alsa_stream;
30 chip->opened |= (1 << idx);
31 - alsa_stream->draining = 1;
34 mutex_unlock(&chip->audio_mutex);
35 @@ -268,6 +267,7 @@ static int snd_bcm2835_pcm_prepare(struc
36 alsa_stream->buffer_size = snd_pcm_lib_buffer_bytes(substream);
37 alsa_stream->period_size = snd_pcm_lib_period_bytes(substream);
39 + alsa_stream->draining = false;
41 audio_debug("buffer_size=%d, period_size=%d pos=%d frame_bits=%d\n",
42 alsa_stream->buffer_size, alsa_stream->period_size,
43 @@ -312,21 +312,15 @@ static int snd_bcm2835_pcm_trigger(struc
45 case SNDRV_PCM_TRIGGER_START:
46 err = bcm2835_audio_start(alsa_stream);
48 - alsa_stream->draining = 1;
51 audio_error(" Failed to START alsa device (%d)\n", err);
53 + case SNDRV_PCM_TRIGGER_DRAIN:
54 + alsa_stream->draining = true;
56 case SNDRV_PCM_TRIGGER_STOP:
57 - if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
58 - audio_info("DRAINING\n");
59 - alsa_stream->draining = 1;
61 - audio_info("DROPPING\n");
62 - alsa_stream->draining = 0;
64 err = bcm2835_audio_stop(alsa_stream);
67 audio_error(" Failed to STOP alsa device (%d)\n", err);