76279ec813fc7e4df30660df899d74bc1dd67206
[openwrt/staging/linusw.git] /
1 From 9dd926d29051324d8621ca2a18bbdd568523ac93 Mon Sep 17 00:00:00 2001
2 From: Takashi Iwai <tiwai@suse.de>
3 Date: Sat, 14 Sep 2019 17:24:05 +0200
4 Subject: [PATCH] staging: bcm2835-audio: Fix draining behavior
5 regression
6
7 The PCM draining behavior got broken since the recent refactoring, and
8 this turned out to be the incorrect expectation of the firmware
9 behavior regarding "draining". While I expected the "drain" flag at
10 the stop operation would do processing the queued samples, it seems
11 rather dropping the samples.
12
13 As a quick fix, just drop the SNDRV_PCM_INFO_DRAIN_TRIGGER flag, so
14 that the driver uses the normal PCM draining procedure. Also, put
15 some caution comment to the function for future readers not to fall
16 into the same pitfall.
17
18 Fixes: d7ca3a71545b ("staging: bcm2835-audio: Operate non-atomic PCM ops")
19 BugLink: https://github.com/raspberrypi/linux/issues/2983
20 Cc: stable@vger.kernel.org
21 Signed-off-by: Takashi Iwai <tiwai@suse.de>
22 ---
23 drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 4 ++--
24 drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 1 +
25 2 files changed, 3 insertions(+), 2 deletions(-)
26
27 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
28 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
29 @@ -12,7 +12,7 @@
30 static const struct snd_pcm_hardware snd_bcm2835_playback_hw = {
31 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
32 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
33 - SNDRV_PCM_INFO_DRAIN_TRIGGER | SNDRV_PCM_INFO_SYNC_APPLPTR),
34 + SNDRV_PCM_INFO_SYNC_APPLPTR),
35 .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
36 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_192000,
37 .rate_min = 8000,
38 @@ -29,7 +29,7 @@ static const struct snd_pcm_hardware snd
39 static const struct snd_pcm_hardware snd_bcm2835_playback_spdif_hw = {
40 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
41 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
42 - SNDRV_PCM_INFO_DRAIN_TRIGGER | SNDRV_PCM_INFO_SYNC_APPLPTR),
43 + SNDRV_PCM_INFO_SYNC_APPLPTR),
44 .formats = SNDRV_PCM_FMTBIT_S16_LE,
45 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
46 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
47 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
48 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
49 @@ -297,6 +297,7 @@ int bcm2835_audio_stop(struct bcm2835_al
50 VC_AUDIO_MSG_TYPE_STOP, false);
51 }
52
53 +/* FIXME: this doesn't seem working as expected for "draining" */
54 int bcm2835_audio_drain(struct bcm2835_alsa_stream *alsa_stream)
55 {
56 struct vc_audio_msg m = {