b2a1309777b65e67bd3b7b3c8509deaa3f79854e
[openwrt/staging/neocturne.git] /
1 From 79b036b042717037d23760dd94ba87ee6ddd5a33 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 443/773] staging: bcm2835-audio: Fix incorrect draining
5 handling
6
7 commit 7d2a91f5f1bcf08ca257bcf1ed9721fcd341f834 upstream.
8
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.
13
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.
17
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>
21 ---
22 .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 18 ++++++------------
23 1 file changed, 6 insertions(+), 12 deletions(-)
24
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;
29
30 chip->opened |= (1 << idx);
31 - alsa_stream->draining = 1;
32
33 out:
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);
38 alsa_stream->pos = 0;
39 + alsa_stream->draining = false;
40
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
44 switch (cmd) {
45 case SNDRV_PCM_TRIGGER_START:
46 err = bcm2835_audio_start(alsa_stream);
47 - if (!err)
48 - alsa_stream->draining = 1;
49 - else
50 + if (err)
51 audio_error(" Failed to START alsa device (%d)\n", err);
52 break;
53 + case SNDRV_PCM_TRIGGER_DRAIN:
54 + alsa_stream->draining = true;
55 + break;
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;
60 - } else {
61 - audio_info("DROPPING\n");
62 - alsa_stream->draining = 0;
63 - }
64 err = bcm2835_audio_stop(alsa_stream);
65 - if (err != 0)
66 + if (err)
67 audio_error(" Failed to STOP alsa device (%d)\n", err);
68 break;
69 default: