aboutsummaryrefslogtreecommitdiffstats
path: root/main/linux-rpi/rpi-dma-i2s-fix.patch
blob: 82fa6dcf7ce8793c9690e56a511933c35528a6ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From 8a2e9aec63f46deceacd0a92a66835a07fb18a31 Mon Sep 17 00:00:00 2001
From: Matthias Reichl <hias@horus.com>
Date: Sun, 8 Nov 2015 16:58:57 +0100
Subject: [PATCH] bcm2708-dmaengine: fix calculation of cyclic DMA frames

The calculation of the number of required frames was wrong which
could lead to the last frame being longer than the requested period
length and even the maximum supported transfer size.

eg when requesting a 88208 bytes buffer with a period len of 22052
(the defaults when playing a 44.1kHz stereo 16bit file with aplay)
the code would allocate 3 frames, two with 22052 bytes and the
last one with 44104 bytes instead of the expected 4 frames with
22052 bytes each.

Signed-off-by: Matthias Reichl <hias@horus.com>
---
 drivers/dma/bcm2708-dmaengine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/bcm2708-dmaengine.c b/drivers/dma/bcm2708-dmaengine.c
index 85ce18b..91eac60 100644
--- a/drivers/dma/bcm2708-dmaengine.c
+++ b/drivers/dma/bcm2708-dmaengine.c
@@ -710,7 +710,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
 		max_size = MAX_NORMAL_TRANSFER;
 	period_len = min(period_len, max_size);
 
-	d->frames = (buf_len-1) / period_len + 1;
+	d->frames = DIV_ROUND_UP(buf_len, period_len);
 
 	/* Allocate memory for control blocks */
 	d->control_block_size = d->frames * sizeof(struct bcm2835_dma_cb);
-- 
2.6.3


From 8e469d0e00fa0f337e0e5ccdb504ce0ecf6ea6d6 Mon Sep 17 00:00:00 2001
From: Matthias Reichl <hias@horus.com>
Date: Sun, 8 Nov 2015 17:00:45 +0100
Subject: [PATCH] bcm2708-i2s: match period_bytes_max to DMA controller limit

bcm2708-dmaengine supports a maximum transfer length of 32k bytes on
the lite channels. period_bytes_max should reflect this limit.

Signed-off-by: Matthias Reichl <hias@horus.com>
---
 sound/soc/bcm/bcm2708-i2s.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/bcm/bcm2708-i2s.c b/sound/soc/bcm/bcm2708-i2s.c
index 5e93cd6..b65d785 100644
--- a/sound/soc/bcm/bcm2708-i2s.c
+++ b/sound/soc/bcm/bcm2708-i2s.c
@@ -881,7 +881,7 @@ static struct snd_pcm_hardware bcm2708_pcm_hardware = {
 				  SNDRV_PCM_FMTBIT_S24_LE |
 				  SNDRV_PCM_FMTBIT_S32_LE,
 	.period_bytes_min	= 32,
-	.period_bytes_max	= 64 * PAGE_SIZE,
+	.period_bytes_max	= SZ_32K,
 	.periods_min		= 2,
 	.periods_max		= 255,
 	.buffer_bytes_max	= 128 * PAGE_SIZE,
-- 
2.6.3